crashkernel

最後更新: 2017-06-01

介紹

 


Package & Requirements

 

It relies on kexec, which can be used to boot a Linux kernel from the context of another kernel,

bypass BIOS, and preserve the contents of the first kernel's memory that would otherwise be lost.

The kdump service is installed and activated by default on new Red Hat Enterprise Linux 7

Package

yum install kexec-tools

Memory Requirements(Reserved memory)

On the x86_64 architecture, the amount of reserved memory will be 160 MB + 2 bits for every 4 KB of RAM.
 


Reserved memory

 

Memory reserved for the kdump kernel is always reserved during system boot,

which means that the amount of memory is specified in the system's boot loader configuration.

crashkernel

"crashkernel=XM@OFFSET" is a kernel parameter for kdump

boot loader configuration

/etc/default/grub

GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet"

grub2-mkconfig -o /boot/grub2/grub.cfg

Example

# Amount of memory you want to reserve

crashkernel=128M

# The kernel will automatically reserve an appropriate amount of memory for the kdump kernel

crashkernel=auto

# Reserve 128 MB of memory starting at 16 MB (physical address 0x01000000).

crashkernel=128M@16M

 * If the offset parameter is set to 0 or omitted entirely, offset the reserved memory automatically.

 


kernel crash dump file

 

dump file location

When a kernel crash is captured, the core dump can be either stored as a file in a local file system,

written directly to a device, or sent over a network using the NFS or SSH protocol.

/etc/kdump.conf

/var/crash/

"vmcore" dump file

collector

kdump allows you to specify an external application (a core collector) to compress the data

core collector: makedumpfile

core_collector makedumpfile -l --message-level 1 -d 31

# -c / -l           # To enable the dump file compression ( -c: zlib / -l: lzo)
# -d                # To remove certain pages from the dump

31 = 1 + 2 + 4 + 8 + 16

1     Zero pages
2     Cache pages
4     Cache private
8     User pages
16    Free pages

 


kdump service

 

systemctl is-active kdump

active

systemctl status kdump

● kdump.service - Crash recovery kernel arming
   Loaded: loaded (/usr/lib/systemd/system/kdump.service; enabled; vendor preset: enabled)
   Active: active (exited) since Wed 2017-04-26 14:46:25 HKT; 1 weeks 5 days ago
  Process: 831 ExecStart=/usr/bin/kdumpctl start (code=exited, status=0/SUCCESS)
 Main PID: 831 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/kdump.service

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

 


Testing kdump (force the Linux kernel to crash)

 

# enable sysrq-trigger

echo 1 > /proc/sys/kernel/sysrq

# c => crash

echo c > /proc/sysrq-trigger

 


 

Creative Commons license icon Creative Commons license icon