Skip to content

Configure kdump so a kernel panic leaves you a vmcore

Set up kdump end to end so the next Linux kernel panic writes a vmcore instead of vanishing: reserve crashkernel memory, enable the service on RHEL-family or Debian/Ubuntu, pick a dump target, shrink the dump with makedumpfile, test it with sysrq, and read the result with crash.

A server rebooted at 03:00, the journal stops mid-sentence, and there is nothing in it that explains why. That gap is not a logging bug — when the kernel panics, it cannot flush anything to disk, so whatever it was about to say is lost with it. The mechanism that fixes this is kdump: a second, minimal kernel preloaded into a reserved slice of RAM, which boots after the panic and writes the dead kernel’s memory to a file called a vmcore. This guide gets that mechanism armed and proven on both RHEL-family and Debian/Ubuntu hosts, so the next panic leaves evidence. It also sets an honest expectation up front: capturing a usable vmcore is a job you can finish today, while fully analysing one is often a matter of extracting a stack trace and handing the file to a kernel vendor.

What you’ll accomplish

  • Reserve crashkernel memory correctly and verify the reservation actually took effect, rather than assuming it did.
  • Enable and configure the dump service under its real name on your distribution — kdump.service with /etc/kdump.conf, or kdump-tools.service with /etc/default/kdump-tools.
  • Choose a dump target that has room: a local path, an SSH host, or an NFS export.
  • Shrink the dump with makedumpfile compression and page filtering so it fits, and estimate the size before the incident.
  • Trigger a real panic on purpose with sysrq and confirm the vmcore landed.
  • Get a first stack trace out of the dump with crash, or at minimum recover the kernel log the panic never got to write.

Prerequisites

  • Root or sudo on the host, plus console access — you are going to deliberately panic this machine, so do it on a host you can reboot and reach out of band.
  • At least 2 GB of RAM. On very small instances the reservation competes with the workload, and under roughly 1 GB kdump is rarely worth the memory it costs.
  • Enough free space on the dump target. A filtered, compressed vmcore is usually a small fraction of RAM, but “usually” is doing real work in that sentence — a host with a large page cache dirty at panic time can produce a much bigger file.
  • The package and service names differ, and getting them wrong is the most common first stumble:
    • RHEL, AlmaLinux, Rocky, CentOS Stream, Fedora: package kexec-tools, service kdump.service, config /etc/kdump.conf, helper kdumpctl.
    • Debian and Ubuntu: package kdump-tools (Ubuntu also ships a linux-crashdump metapackage that pulls in the debug symbols too), service kdump-tools.service, config /etc/default/kdump-tools, helper kdump-config.
  • Boot parameters are edited differently too: grubby on RHEL-family, /etc/default/grub plus update-grub on Debian/Ubuntu.
  • Under Secure Boot the capture kernel must be signed by a trusted key, so a kexec -p that fails with a permission error has probably hit that and not a config mistake.

How it works

Nothing about a panic is graceful. The kernel has decided it cannot continue, and by definition it can no longer be trusted to run its own storage stack. So kdump does not try to write anything from the broken kernel. Instead, at boot time the kernel sets aside a region of physical memory that it will never allocate from — the crashkernel reservation. A second kernel and a small initramfs are loaded into that region ahead of time by kexec -p, where they sit idle. When the panic fires, the panic path jumps straight into that preloaded kernel via kexec, skipping firmware and skipping the reset that would wipe RAM.

Diagram of the kdump mechanism: at boot a crashkernel region is reserved inside system RAM alongside the production kernel and holds a capture kernel loaded by kexec -p; on kernel panic the system kexecs into that reserved region rather than rebooting, the capture kernel reads the old kernel memory through /proc/vmcore, makedumpfile compresses and filters it, and the vmcore is written to a local path, SSH or NFS target before the host reboots normally

The capture kernel comes up in that small reserved region with almost no memory and no normal userspace. What it does have is /proc/vmcore, a view of the previous kernel’s physical memory, which its tiny init script copies out through makedumpfile. Once the copy completes, the host reboots for real.

Two consequences explain most kdump failures. If the reservation did not happen at boot, there is nowhere for the capture kernel to live and the panic simply reboots the box with nothing written. And kdump only helps for events that reach the kernel’s panic path — a hypervisor reset, a power loss or a hard watchdog reset never gets there, and no amount of configuration will produce a vmcore for them.

Step-by-step

Decision tree for a server that rebooted with nothing in the logs: check whether crashkernel memory is reserved with cat /sys/kernel/kexec_crash_size, whether the kdump or kdump-tools service is active, whether the dump target is writable and large enough with df -h /var/crash, and whether the event was really a kernel panic rather than a hardware or hypervisor reset; each failed check has its fix, and passing all four means the vmcore lands under /var/crash with a vmcore-dmesg.txt beside it

  1. Install the tooling. Pick the line for your distribution.

    sudo dnf install -y kexec-tools
    sudo apt install -y kdump-tools

    The Debian/Ubuntu package asks two debconf questions during install — whether to enable kdump, and whether to reboot now — and it writes a crashkernel reservation into a GRUB drop-in for you. The RHEL-family package does not prompt, but recent installs already carry a crashkernel= value on the command line.

  2. Check whether memory is already reserved. This is the single most informative command in the whole exercise.

    cat /sys/kernel/kexec_crash_size
    cat /proc/cmdline

    Expected on a host where the reservation worked — a byte count, and a matching parameter:

    268435456
    BOOT_IMAGE=/vmlinuz-5.14.0-427.el9.x86_64 root=/dev/mapper/rl-root ro crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M

    A 0 means nothing was reserved, and everything else you configure will be inert. If /proc/cmdline has no crashkernel= at all, go to step 3.

  3. Set the reservation and reboot. The ranged syntax means “reserve this much for a host with this much RAM”, so one line covers a fleet of mixed sizes. On RHEL-family:

    sudo grubby --update-kernel=ALL --args="crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M"
    sudo grubby --info=ALL | grep -m1 args

    Expected: the args= line now contains your crashkernel= value. On Debian/Ubuntu, edit GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub (or the drop-in the package created under /etc/default/grub.d/) to include the same parameter, then:

    sudo update-grub

    Expected: Generating grub configuration file ... followed by done. Reboot, then re-run step 2 and confirm kexec_crash_size is non-zero.

  4. Choose the dump target. On RHEL-family this lives in /etc/kdump.conf. The defaults write to the root filesystem:

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

    To send the dump to another host instead, replace the path with an ssh or nfs line:

    ssh kdump@dumps.example.net
    sshkey /root/.ssh/kdump_id_rsa
    path /srv/vmcores
    core_collector makedumpfile -F -l --message-level 7 -d 31

    The -F flag makes makedumpfile write to standard output so the dump can be streamed over the SSH connection; it is required for an ssh target and wrong for a local one. Push the key to the target with:

    sudo kdumpctl propagate

    Expected: /root/.ssh/kdump_id_rsa.pub has been added to ~kdump@dumps.example.net/.ssh/authorized_keys2. On Debian/Ubuntu the same choices live in /etc/default/kdump-tools:

    USE_KDUMP=1
    KDUMP_COREDIR="/var/crash"
    MAKEDUMP_ARGS="-c -d 31"
  5. Understand the filtering flags before you copy them. -d takes a bitmask of page types to exclude: 1 zero pages, 2 non-private cache pages, 4 private cache pages, 8 user data pages, 16 free pages. -d 31 is all five, and it is the standard choice because none of those page types normally says anything about why the kernel died. Compression is -c for zlib, -l for lzo and -p for snappy — lzo is much faster to write, which matters when the capture kernel is copying gigabytes with a watchdog running. On RHEL 9 you can ask for a size estimate before the incident:

    sudo kdumpctl estimate

    Expected: a short report naming a recommended crashkernel size and an estimated dump size, for example Reserved crashkernel: 256M alongside Recommended crashkernel: 210M.

  6. Enable and start the service. Same idea, different names.

    sudo systemctl enable --now kdump.service
    systemctl is-active kdump.service
    sudo systemctl enable --now kdump-tools.service
    systemctl is-active kdump-tools.service

    Expected: active in both cases. Starting the service is what builds the capture initramfs and calls kexec -p, so the first start is slow — tens of seconds is normal.

  7. Confirm the capture kernel is actually loaded. An active service is not the same thing as a loaded kernel.

    cat /sys/kernel/kexec_crash_loaded

    Expected: 1. A 0 here with an active service means kexec -p failed, and the reason will be in journalctl -u kdump.service -b (or -u kdump-tools.service). For a fuller report:

    sudo kdumpctl status
    sudo kdump-config status

    Expected on Debian/Ubuntu: current state : ready to kdump.

Validate it works

Do not skip this. A kdump configuration that has never been tested has a genuinely poor track record, because most of the failure modes only appear at the moment of the panic.

Confirm the dump target has room for the estimate you got in step 5:

df -h /var/crash

Then panic the machine on purpose. This is a real, immediate crash — every unsaved thing on the host is lost, so treat it as a maintenance window:

sudo sysctl -w kernel.sysrq=1
echo c | sudo tee /proc/sysrq-trigger

Expected: the session dies instantly. On the console you will see sysrq: Trigger a crash followed by a Kernel panic - not syncing: sysrq triggered crash banner, then the capture kernel booting and makedumpfile printing a progress percentage as it copies. The host reboots on its own when the copy finishes.

When it is back, look for the dump:

ls -lh /var/crash/*/

Expected on RHEL-family — a timestamped directory named after the host address, containing the dump and a plain-text kernel log:

/var/crash/10.0.0.12-2026-08-04-03:12:44/:
total 214M
-rw-------. 1 root root 214M Aug  4 03:14 vmcore
-rw-------. 1 root root  92K Aug  4 03:14 vmcore-dmesg.txt

Debian/Ubuntu names things differently: a directory like /var/crash/202608040312/ holding dump.202608040312 and dmesg.202608040312. Read the log first, because it is the part that needed no debug symbols and it contains the panic message the journal never got:

sudo tail -n 40 /var/crash/*/vmcore-dmesg.txt

If your setup did not produce that file, extract the log from the dump directly:

sudo makedumpfile --dump-dmesg /var/crash/*/vmcore /tmp/dmesg.txt

Expected: The dmesg log is saved to /tmp/dmesg.txt. followed by makedumpfile Completed.

For a first pass of real analysis you need crash and a debug kernel whose build matches the crashed one exactly. On RHEL-family:

sudo dnf install -y crash
sudo dnf debuginfo-install -y kernel-$(uname -r)
sudo crash /usr/lib/debug/lib/modules/$(uname -r)/vmlinux /var/crash/10.0.0.12-2026-08-04-03:12:44/vmcore

At the crash> prompt, three commands answer most first questions: bt prints the backtrace of the task that panicked, log prints the kernel ring buffer, and ps lists the processes as they were at the moment of death. bt -a gives you the backtrace on every CPU, which is what you want for a lockup rather than a straightforward oops. Exit with exit.

Troubleshooting

  • kexec_crash_size is 0 after a reboot. The kernel could not find a contiguous block where it wanted one. Check the boot log with dmesg | grep -i crashkernel; crashkernel reservation failed - memory is in use or No suitable area found are the two you will see. On x86_64 with lots of RAM or an awkward firmware memory map, ask for the reservation above the 4 GB line with crashkernel=512M,high, which also reserves a small low region automatically. Reboot and re-check.
  • The service is active but kexec_crash_loaded is 0. The capture initramfs failed to build, usually because a driver needed to reach the dump target is missing from it, or because the reservation is too small to boot into. Rebuild it explicitly with sudo kdumpctl rebuild (or sudo kdump-config load) and read the output — dracut reports the missing module by name. On Secure Boot hosts, a kexec_file_load permission failure here means the capture kernel image is not signed by a key the running kernel trusts.
  • The dump target ran out of space mid-copy. You get a truncated vmcore that crash refuses to open. Either free space, or stop dumping to the root filesystem: an ssh or nfs target moves the problem to a host with room. Size it against kdumpctl estimate, and remember that -d 31 filtering only helps if the excluded pages are actually the bulk of your memory.
  • The SSH dump hangs or times out. The capture kernel has a minimal network stack and no name resolution to speak of. Use an IP address rather than a hostname in the ssh line, make sure the interface driver is included in the capture initramfs, and confirm the target host’s authorized_keys2 really received the key from kdumpctl propagate. A dump that stalls with a watchdog armed will be cut short by the watchdog, so raise the timeout or disable the hardware watchdog for the capture kernel via dracut_args.
  • A cloud VM rebooted and there is no vmcore at all, even though kdump is configured. Check whether it was a panic in the first place. A hypervisor-initiated reset, live migration failure or host maintenance event never enters the panic path, and the provider’s console log or instance event history is the only place that story exists. Similarly, if the guest was killed by the host for exceeding a memory limit, the kernel never panicked — that is a different investigation, closer to how the OOM killer picks its victim.

When this is the wrong approach

kdump costs memory permanently — a few hundred megabytes carved out of every host, forever, for an event that may never happen. On a fleet of small, disposable application nodes that trade is often not worth making. Reserve it for hosts where a panic is expensive and unexplained reboots have actually occurred: database primaries, hypervisors, storage nodes, anything carrying an out-of-tree or vendor driver.

It is also the wrong tool for anything the kernel survives. If the box is merely slow, thrashing, or losing one service at a time, you want live diagnostics, and tuning work such as kernel sysctl settings is a more productive place to spend the afternoon. A vmcore is a photograph of a dead system; it tells you nothing about a sick one.

Finally, be realistic about the analysis. Reading bt and log will often name the module or subsystem involved, which is usually enough to open a well-formed support case or match a known upstream bug. Going further — walking kernel data structures, reconstructing a race — is specialist work, and if the panic came from a vendor driver or a distribution kernel, the fastest path is to hand the vmcore and the matching kernel version to the people who compiled it. The kernel’s own kdump documentation covers the mechanism in detail, and Red Hat’s product documentation carries the distribution-specific configuration and the vendor’s expectations for what a submitted dump should contain.

If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.