How to use kdump for kernel crash analysis
· Category: Linux
Short answer
kdump captures a memory dump (vmcore) when the kernel crashes, enabling post-mortem analysis.
Steps
- Install kdump tools:
sudo apt install linux-crashdump
- Reserve crash kernel memory in grub config.
- Enable and start:
sudo systemctl enable kdump-tools
- Test with a sysrq trigger:
echo c | sudo tee /proc/sysrq-trigger
- Analyze the vmcore with
crash.
Tips
- Store vmcore on a dedicated partition or network location.
- Filter zero pages to reduce dump size.
- Automate vmcore collection in production environments.
Common issues
- Insufficient reserved memory causes kdump to fail.
- Secure boot may prevent kexec from loading the crash kernel.