diff --git a/srcpkgs/runit-kdump/INSTALL.msg b/srcpkgs/runit-kdump/INSTALL.msg new file mode 100644 index 00000000000..55350783baa --- /dev/null +++ b/srcpkgs/runit-kdump/INSTALL.msg @@ -0,0 +1,8 @@ +To enable loading the crash kernel, append crashkernel=128M to the +Linux command line. + +By default, crash dumping will use the default initrd and dump in +runit stage 1 to /var/crash. + +You can place a custom initrd used for crash dumping as +/boot/initramfs-${KERNELVERSION}kdump.img. diff --git a/srcpkgs/runit-kdump/files/90-kdump.sh b/srcpkgs/runit-kdump/files/90-kdump.sh new file mode 100644 index 00000000000..b055a4e6042 --- /dev/null +++ b/srcpkgs/runit-kdump/files/90-kdump.sh @@ -0,0 +1,32 @@ +if [ -e /proc/vmcore ] && ! grep -q nokdump /proc/cmdline ; then + DIR="/var/crash/$(date +%Y%m%d-%H%M%S)" + msg "Found kernel crash dump, saving vmcore to $DIR...\n" + mkdir -p "$DIR" + makedumpfile -l --message-level 1 -d 31 /proc/vmcore "$DIR"/vmcore.incomplete && + mv "$DIR"/vmcore.incomplete "$DIR"/vmcore + msg "Found kernel crash dump, saving dmesg to $DIR...\n" + vmcore-dmesg /proc/vmcore >"$DIR"/vmcore-dmesg.txt.incomplete && + mv "$DIR"/vmcore-dmesg.txt.incomplete "$DIR"/vmcore-dmesg.txt + sync + touch /run/runit/reboot + msg "Crash dump done, triggering reboot.\n" + exit 100 # force reboot +fi + +if [ $(cat /sys/kernel/kexec_crash_size) = 0 ]; then + msg_warn "Loading crash kernel skipped, booted without crashkernel=NNN.\n" +else + KVER="$(uname -r)" + if [ -f /boot/initramfs-${KVER}kdump.img ]; then + INITRD=/boot/initramfs-${KVER}kdump.img + else + INITRD=/boot/initramfs-${KVER}.img + fi + + APPEND="irqpoll nr_cpus=1 maxcpus=1 reset_devices udev.children-max=2 panic=10 cgroup_disable=memory mce=off numa=off" + + msg "Loading crash kernel..." + kexec --load-panic /boot/vmlinuz-${KVER} \ + --initrd="$INITRD" --reuse-cmdline --append="$APPEND" && + msg_ok +fi diff --git a/srcpkgs/runit-kdump/template b/srcpkgs/runit-kdump/template new file mode 100644 index 00000000000..e57bb8cc15a --- /dev/null +++ b/srcpkgs/runit-kdump/template @@ -0,0 +1,15 @@ +# Template file for 'runit-kdump' +pkgname=runit-kdump +version=20150226 +revision=1 +noarch=yes +make_dirs="/var/crash 0755 root root" +depends="runit-void makedumpfile kexec-tools" +short_desc="Crashkernel/kdump support for runit to save vmcore to disk" +maintainer="Christian Neukirchen " +license="Public Domain" +homepage="http://www.voidlinux.eu/" + +do_install() { + vinstall ${FILESDIR}/90-kdump.sh 0644 etc/runit/core-services +}