Dumping a Linux Kernel

tested on Ubuntu/xenial and Devuan/ascii

Warning: if running Linux as a dom0 on top of a XEN micro-kernel, some specific steps need to be taken: https://xenbits.xen.org/docs/4.10-testing/misc/kexec_and_kdump.txt.

This is usually available,

less /boot/config-4.9.0-6-amd64

CONFIG_RELOCATABLE=y
CONFIG_KEXEC=y
CONFIG_CRASH_DUMP=y
CONFIG_DEBUG_INFO=y

CONFIG_MAGIC_SYSRQ=y
CONFIG_PROC_VMCORE=y

On Ubuntu,

locale
apt install linux-crashdump
apt install linux-image-generic linux-headers-generic linux-tools-generic

Should kexec-tools handle reboots? ==> Yes
Should kdump-tools be enabled by default? ==> Yes

On Devuan,

apt install crash kexec-tools makedumpfile
apt install linux-image-amd64 linux-headers-amd64 linux-tools

On both,

vi /dev/default/kdump-tools
vi /dev/default/kexec
uname -a
dpkg -l | grep linux-image
ls -alhF /lib/modules
poweroff

restart the guest/system adding this to the kernel boot arguments,

#crashkernel=auto
#crashkernel=128M@16M
#crashkernel=0M-2G:128M,2G-6G:256M,6G-8G:512M,8G-:768M
#crashkernel=256M
crashkernel=128M

shutdown the system, otherwise if you reboot it might just reload the kernel already,

poweroff
#dpkg-reconfigure kdump-tools
#dpkg-reconfigure kexec-tools

physically power on and check,

#ubuntu
systemctl status kdump-tools

#devuan
service kdump-tools status

dmesg | grep -i crash
cat /proc/cmdline
cat /proc/sys/kernel/sysrq #should be >0
kdump-config status
kdump-config show
kdump-config test
sysctl -a | grep oops

ls -lhF /var/lib/kdump/initrd.img
ls -lhF /var/lib/kdump/vmlinuz
ls -alhF /var/crash

Ready to go

Let’s proceed with a crash dump,

cat /sys/kernel/kexec_crash_loaded
echo c > /proc/sysrq-trigger
#cat /sys/kernel/kexec_loaded

Analyzing the core dump

cd /var/crash/201804292156
crash /usr/lib/debug/vmlinux-4.9.0-6-amd64 dump.201804292156

References

Compile

Troubleshooting kdump setup

Troubleshooting /var/crash


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun