How to: Create a memory dump in Linux
Description and cautions
This article describes how to configure dump for capturing memory dumps, including application memory.
Details
The recommended text editor is nano, below is a quick tutorial on how to use it if you are using it for the first time.
-
To open a file
nano <path to file>
-
To open a file as root, which is required for all file edits in this article
sudo nano <path to file>
-
Basic hotkeys
- Exit without saving - Ctrl+X, N, Enter
- Save and exit - Ctrl+O, Enter, Ctrl+X
- Find - Ctrl+W
- Find and replace - Ctrl+\
-
Configure
kdump-
Altlinux
There is nokdump-toolspackage in the default repository, so it has to be downloaded from the sisyphus repository:- Go to https://packages.altlinux.org/en/sisyphus/srpms/kdump-tools/
-
In List of rpms provided by this srpm select the
kdump-toolspackage for the required architecture (can be checked by runninguname -m) - Download the package from the Download link
-
Install it by running
apt-get update && apt-get install <path to the downloaded rpm>
-
After that, follow the Debian instruction from Edit /etc/default/kdump-tools step
-
Red Hat based distributions (tested on Fedora 38, Rocky Linux 9, Red OS)
-
Install
kexec-toolssudo dnf install kexec-tools -
Edit
/etc/kdump.conf.In the configuration file edit thecore_collectorsetting: option-dshould be set to17instead of31 -
Edit
/etc/default/grub.EditGRUB_CMDLINE_LINUX, addcrashkernel=256Mto reserve enough RAM for the dump kernel to run, andnmi_watchdog=1, to capture a dump in case of a system hang -
Run
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
- Reboot
-
Enable
kdumpservicesudo systemctl enable --now kdump.service
-
-
Debian based distributions (tested on Debian, Astra CE, Alt Linux)
-
Install
kdump-toolssudo apt update && sudo apt install kdump-tools -y
-
Edit
/etc/default/kdump-tools. In the configuration file edit theMAKEDUMP_ARGSvariable: option-dshould be set to17instead of31 -
Configure the bootloader
-
In
/etc/default/grubeditGRUB_CMDLINE_LINUX_DEFAULT, addnmi_watchdog=1to capture a dump in case of a system hang -
In
/etc/default/grub.d/kdump-tools.cfgchangecrashkernelvalue to 384M-:256M (default is 384M-:128M)
Expected result:GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT crashkernel=384M-:256M" -
ave and run
sudo update-grub
-
In
-
-
SUSE Linux
-
Install
kdumpsudo zypper in kdump kexec-tools
-
Edit
/etc/sysconfig/kdump
ChangeKDUMP_DUMPLEVELvariable to17 -
Edit
/etc/default/grub
EditGRUB_CMDLINE_LINUX_DEFAULT, addcrashkernel=256Mto reserve enough RAM for the dump kernel to run, andnmi_watchdog=1, to capture a dump in case of a system hang -
Update the bootloader configuration
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
-
Reboot
-
Enable
kdumpservicesudo systemctl enable --now kdump.service
-
-
Altlinux
-
Configure SysRq dump trigger
To enable SysRq trigger, these key combinations 'kernel.sysrq = 8'(without quotes) has to be added to/etc/sysctl.conf.In SUSE the value of kernel.sysrq has to be changed in
/usr/lib/sysctl.d/50-default.confinstead of/etc/sysctl.conf -
Reboot or run
sudo sysctl --system -
After the set up above is complete, to manually trigger a dump press Alt+SysRq, Alt+C. Alternatively:
echo 8 | sudo tee /proc/sys/kernel/sysrq
(Command above is only needed if
kernel.sysrqis not set in/etc/sysctl.conf)echo c | sudo tee /proc/sysrq-trigger
-
Location of the dump files may vary between different Linux versions, it is configurable in the
kdumpconfiguration file. In Debian based distributions it is set byKDUMP_COREDIRvariable. In Red Hat based distributions it is set by thepathsetting, generally the default location is/var/crash. Make sure that the dump folder has enough free space for the dump to be written. You may search byfilemask: vmcore.
0 Comments
Recommended Comments
There are no comments to display.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now