Configuring kdump on CentOS Stream 9: Capturing and Analyzing vmcore on Kernel Panic

CentOS tutorial - IT technology blog
CentOS tutorial - IT technology blog

The Nightmare of an Untraceable Server Crash

It’s 2:00 AM, and the payment gateway suddenly drops completely offline. Ping requests time out. SSH sessions disconnect. The iDRAC/IPMI console glows with a bright red Kernel Panic alert before the server abruptly reboots itself.

You scramble to SSH back in and inspect /var/log/messages or journalctl, only to find the system logs cut off at the exact moment of failure. No stack trace. Not a single clue left behind.

The next morning, your team lead and clients demand a post-mortem report. If all you have to offer is ‘maybe a voltage drop’ or ‘a temporary network hiccup’, you lose their trust on the spot. While migrating 12 production nodes from CentOS 8 to Rocky/CentOS Stream 9 a while back, I lost three sleepless nights to random panics triggered by a legacy Broadcom fiber NIC driver. Without kdump enabled from day one, you are completely defenseless against low-level kernel bugs like that.

How Do kdump and vmcore Work?

Imagine your server as a commercial airliner. In mid-air, the primary engine suddenly explodes (a Kernel Panic). At that moment, the pilot cannot simultaneously steer the plane and write down an accident report.

The system needs an independent black box. That is precisely the role of kdump (Kernel Crash Dump) in Linux. Leveraging the kexec mechanism, Linux instantly boots a tiny secondary kernel (the capture kernel), which resides in a reserved memory area pre-allocated at boot time.

When the main kernel crashes, the capture kernel springs to life. It captures a complete snapshot of system memory at the time of failure, compresses it into a vmcore file, writes it to disk, and only then triggers a clean reboot.

Three Core Concepts You Must Know:

  • Kernel Panic: A fatal internal state where the Linux kernel encounters an unrecoverable error and halts immediately to prevent data corruption on disk.
  • crashkernel: A dedicated portion of RAM reserved at boot time exclusively for kdump in the event of a crash.
  • vmcore: A memory snapshot taken at the exact instant the system crashes—the definitive ‘crime scene’ needed to determine the root cause.

6 Steps to Set Up and Analyze kdump on CentOS Stream 9

Here is a battle-tested production workflow to deploy this safety net across your infrastructure.

Step 1: Install kexec-tools and the crash Utility

First, install the two essential packages:

sudo dnf install -y kexec-tools crash

Here, kexec-tools handles loading the capture kernel into reserved memory, while crash is used to inspect and analyze the generated vmcore file.

Step 2: Configure Reserved RAM for the Crash Kernel

CentOS Stream 9 supports the dynamic crashkernel=auto parameter. However, on heavy-workload production servers, you should allocate a fixed memory size to prevent out-of-memory errors during dumps. For servers with 16GB to 64GB of RAM, 256M or 512M is typically ideal.

Check the current bootloader parameters:

cat /proc/cmdline | grep crashkernel

Update the reserved memory allocation using grubby:

sudo grubby --update-kernel=ALL --args="crashkernel=256M"

After updating the parameter, reboot the server so GRUB can reserve this dedicated memory region:

sudo reboot

Step 3: Configure Dump Path and Compression

Open /etc/kdump.conf to adjust the configuration:

sudo vi /etc/kdump.conf

Ensure the following two lines are active:

path /var/crash
core_collector makedumpfile -l --message-level 7 -d 31

The -d 31 flag in makedumpfile is critical. It filters out free memory pages, cache buffers, and user-space data, retaining only essential kernel memory. As a result, a crashed server with 64GB of RAM generates a dump of only around 300MB to 800MB instead of consuming a full 64GB of disk space.

Step 4: Enable the kdump Service

Enable and start the kdump systemd service:

sudo systemctl enable --now kdump.service

Verify its status:

sudo kdumpctl status
# Expected output: kdump: Kdump is operational

Step 5: Test with a Simulated Crash

Never trust a backup or dump mechanism you haven’t drill-tested. We can trigger a controlled Kernel Panic using SysRq via sysctl (Warning: Perform this only in a Staging or Lab environment):

# Enable SysRq controls
sudo sysctl -w kernel.sysrq=1

# Trigger an immediate kernel panic
sudo sh -c 'echo c > /proc/sysrq-trigger'

Your SSH session will drop immediately. Control passes to kdump, which writes the memory snapshot to disk and reboots the system in roughly 60 to 90 seconds.

Step 6: Dissect the Crash Scene with the crash Utility

Once the server finishes rebooting, navigate to the crash directory:

cd /var/crash/127.0.0.1-*
ls -lh

You will see two files: vmcore-dmesg.txt (kernel ring buffer logs right before the crash) and vmcore (the full memory snapshot). Inspect the kernel log first:

tail -n 35 vmcore-dmesg.txt

The log will clearly show the line ‘SysRq : Trigger a crash’. For an in-depth call stack analysis, install the debug symbols and launch the crash tool:

# Install matching kernel debuginfo for the running kernel
sudo dnf install -y kernel-debuginfo-$(uname -r) --enablerepo=baseos-debuginfo

# Open the dump file alongside the debug symbol kernel image
sudo crash /usr/lib/debug/lib/modules/$(uname -r)/vmlinux vmcore

Inside the crash interactive shell, run bt (Backtrace) to view the call stack:

crash> bt
# The backtrace highlights the exact function, driver module, or instruction pointer (RIP) responsible for the crash!
crash> q

Conclusion: 10 Minutes of Configuration for Complete Peace of Mind

Unexplained server crashes in production mean lost revenue and damaged technical credibility. Taking 10 minutes to configure kdump on CentOS Stream 9 during initial provisioning gives you a dependable forensic black box. Whether it’s hardware failure, faulty RAM, or a driver conflict in a NIC or SAN switch, you will uncover the real cause—sparing your team from pulling all-nighters chasing shadows.

Share: