What is Linux Kernel crash dump? How to install and enable kdump in Linux Ubuntu Systems? A Kernel Crash Dump refers to a portion of the contents of volatile memory (RAM) that is copied to disk whenever the execution of the kernel is disrupted. It may arise due to the following reasons:
- Kernel Panic
- Non Maskable Interrupts (NMI)
- Machine Check Exceptions (MCE)
- Hardware failure
- Manual intervention
For some of those events (panic, NMI) the kernel will react automatically and trigger the crash dump mechanism through kexec. In other situations a manual intervention is required in order to capture the memory. Whenever one of the above events occurs, it is important to find out the root cause in order to prevent it from happening again. The cause can be determined by inspecting the copied memory contents.
kdump is a feature of the Linux kernel that creates crash dumps in the event of a kernel crash. When triggered, kdump exports a memory image (also known as vmcore) that can be analyzed for the purposes of debugging and determining the cause of a crash.
A Kernel Crash Dump refers to a portion of the contents of volatile memory (RAM) that is copied to disk whenever the execution of the kernel is disrupted. A Kernel Memory Dump contains all the memory in use by the kernel at the time of the crash.
Kdump uses kexec to quickly boot to a dump-capture kernel whenever a dump of the system kernel’s memory needs to be taken (for example, when the system panics). The system kernel’s memory image is preserved across the reboot and is accessible to the dump-capture kernel. You can use common commands, such as cp and scp, to copy the memory image to a dump file on the local disk, or across the network to a remote system. Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64, s390x, arm and arm64 architectures.
When the system kernel boots, it reserves a small section of memory for the dump-capture kernel. This ensures that ongoing Direct Memory Access
(DMA) from the system kernel does not corrupt the dump-capture kernel. The kexec -p command loads the dump-capture kernel into this reserved memory.
Install kernel crash dump utility
The kernel crash dump utility is installed with the following command:
sudo apt install linux-crashdump
Please note that starting with 16.04, the kernel crash dump mechanism is enabled by default. During the installation, you will be prompted, unless chosen otherwise, the kdump mechanism will be enabled. During the installation, you may get the message:
If you choose this option, the kdump-tools mechanism will be enabled. A reboot is still required in order to enable the crashkernel kernel parameter. Should kdump-tools be enabled by default?
Also note that if you ever need to manually enable the functionality, you can use the dpkg-reconfigure kdump-tools command and answer Yes to the question. If a reboot has not been done since installation of the linux-crashdump package, a reboot will be required in order to activate the crashkernel= boot parameter. Upon reboot, kdump-tools will be enabled and active.
If you enable kdump-tools after a reboot, you will only need to issue the kdump-config load command to activate the kdump mechanism.