Kdump is a reliable tool used in Linux to capture kernel crash dumps (vmcores) when the system encounters a kernel panic. Here's a step-by-step guide to install and configure Kdump on a CentOS-based system:
Step 1: Install Kdump
-
Update the package repository:
bash
-
sudo yum update
-
Install the Kdump package:
bash
-
sudo yum install kexec-tools crash
Step 2: Configure Kdump
-
Open the Kdump configuration file in a text editor:
bash
-
sudo nano /etc/kdump.conf
-
Configure the destination for the vmcore. By default, Kdump saves the dump in
/var/crash
. You can adjust this location if needed.Example:
bash
-
path /var/crash
-
Save and close the file.
Step 3: Configure Grub
-
Open the Grub configuration file:
bash
-
sudo nano /etc/default/grub
-
Add or modify the
crashkernel
option. This determines how much memory to reserve for Kdump. Set an appropriate value based on your system's requirements.Example:
makefile
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet crashkernel=256M"
Make sure to regenerate the Grub configuration file:
-
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Step 4: Enable and Start Kdump Service
-
Enable the Kdump service:
bash
-
sudo systemctl enable kdump
-
Start the Kdump service:
bash -
sudo systemctl start kdump
-
Verify that the Kdump service is running:
bash
-
sudo systemctl status kdump
Step 5: Test Kdump
-
Trigger a Kernel Panic:
You can do this by running:
bash
-
sudo echo c > /proc/sysrq-trigger
This simulates a kernel panic.
-
Check for Vmcore:
After the system reboots, check if a vmcore file has been generated in the specified path (e.g.,
/var/crash
).
Additional Tips:
-
Monitor Disk Space: Make sure you have enough free space in the directory where Kdump saves the vmcores.
-
Adjust Memory Allocation: Depending on your system, you may need to adjust the
crashkernel
value in the Grub configuration. -
Debugging with Crash Tool: You can use the
crash
tool to analyze the vmcore. Install itsudo yum install crash
and then runcrash /usr/lib/debug/usr/lib/modules/$(uname -r)/vmlinux /var/crash/...
it to analyze a specific vmcore.
Remember to back up your data and configuration files before making significant changes to your system. If you encounter any issues, consult your system's documentation or seek help from a professional or community forum.