SlideShare a Scribd company logo
Kdump & Kernel crash dump analysis
Part: 1
Introduction to kdump
Part: 2
Introduction to kernel crash dump analysis
http://people.redhat.com/gtiwari/fudcon/
Introduction to Kdump
Buland Singh
 Red Hat 
Introduction to Kdump
What is kexec ?
 How does it work ?
 What is kdump ?
 How does it work ?
 How to configure kdump ?
 How to test kdump setup ?
 How to verify kernel crash dump (vmcore) ?
 References
What is kexec ?
kexec is a fast­boot mechanism that allows booting a kernel 
from the context of an already running kernel without going 
through BIOS or passing through the boot­loader stage.
kexec performs the function of the boot loader from within the 
kernel and when the system boots a kernel with kexec, it skips 
the boot­loader stage. 
This has the effect of reducing the time required for a reboot. 
Kexec include two components:
 User Space Tool    : /usr/sbin/kexec
 o The binary /usr/sbin/kexec is provided "kexec­tools" package.
 Kernel System Call : kexec_load()
 o The Linux kernel configuration "CONFIG_KEXEC" enables the     
   kexec system call.
# grep "CONFIG_KEXEC=" /boot/config­4.0.4­301.fc22.x86_64 
  CONFIG_KEXEC=y
Use of kexec:
Faster system reboots.
Booting without GRUB or LILO boot loader.
Saving the dump of a crashed kernel.
Using kexec: 2 Step process
Loading a new kernel into the physical memory.
# kexec ­l 
Rebooting with the pre­loaded kernel.
# kexec ­e
Kexec Design:
Kexec command:
 Command to load the kernel in memory:
 # kexec ­l <kernel­image> ­­initrd=<initrd­image> ­­append=<command­line­options>
kernel­image : Path of the kernel file.
initrd­image : Path of the initrd image to be used during boot.
Command­line­options : The command­line parameters for new kernel.
 Command to boot with the pre­loaded kernel:
 # kexec ­e
 Command to unload the kernel which was loaded with the kexec ­l command.
 # kexec ­u
Kexec command:
Command to load a kernel to boot at the time of kernel panic.
# kexec ­p <kernel­image> ­­initrd=<initrd­image> ­­append=<command­line­options>
Command to unload the kernel which was loaded with the kexec ­p command.
# kexec ­u ­p
Command to check the status of kexec kernel.
# cat /sys/kernel/kexec_loaded
0 – kernel is not loaded in the memory.
1 – kernel is loaded in the memory.
Demo:
What is kdump ?
  Kdump is a reliable kexec based crash dumping mechanism for Linux.
  Kdump functionality is broken mainly in two components; 
o User space (kexec)
  
   /usr/sbin/kexec 
 
  # grep "CONFIG_KEXEC=" /boot/config­4.0.4­301.fc22.x86_64 
    CONFIG_KEXEC=y
o Kernel space (kdump)
  # grep CRASH_DUMP /boot/config­4.0.4­301.fc22.x86_64 
    CONFIG_CRASH_DUMP=y
What is kdump ?
 Kdump need two different kernel:
  o Standard (production) kernel.
  o Crash (capture) kernel.
 The crash dumps are captured from the context of a freshly booted kernel; not from the context of the    
 crashed kernel. 
 
 Kdump can be configured to dump either directly to a device, to a file, or to some remote location 
 on the network via NFS or SSH.
 Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64, and s390/s390x architectures.
Kdump Design:
How does it works ?
Whenever the standard (production) kernel crashes, kdump uses kexec to boot 
into a crash (capture) kernel. 
This crash (capture) kernel boots with very little pre­reserved memory and 
captures the dump image.
The standard (production) kernel reserves a section of memory that the 
crash (capture) kernel uses to boot. 
Be aware that the memory reserved for the kdump kernel at boot time cannot 
be used by the standard kernel.
Kexec enables booting the capture kernel without going through the BIOS, so 
contents of the first kernel's memory are preserved, which is essentially 
the kernel crash dump. 
What is kernel crash dump (vmcore) ? 
Kernel crash dump captures the state of kernel at the moment 
of panic.
Kernel crash dump is a snapshot of the physical memory at the 
time of crash.
Who needs kernel crash dump & why ? 
Kernel developers : 
To identify the cause of kernel panic. It helps them to fix 
the bug.
Enterprise customer : 
To patch the servers with a bug fix kernel package in­order to 
avoid the downtime in future.
Kdump Configuration files: 
The following two configuration files are used to configure kdump.
 /etc/sysconfig/kdump  
 o Configuration file for kexec kernel. 
 o Use to pass additional boot parameters to kexec kernel.     
 /etc/kdump.conf       
 o Configuration file for kdump service. 
 o Use to set dump taget (local/remote).
 o Use to set default action in case kdump failed.
How to configure kdump ? 
Install kexec­tools package.
Reserve memory for kdump kernel.
Reboot.
Set dump target (Local/Remote) for kdump.
Enable and start kdump service.
Demo:
Step: 1
Install "kexec­tools" package.
# dnf install kexec­tools
Verify "kexec­tools" package.
# rpm ­q kexec­tools
kexec­tools­2.0.8­8.fc22.x86_64
Step: 2
Set kernel boot parameter "crashkernel" to reserve memory for crash/kdump kernel.
# vi /etc/sysconfig/grub
GRUB_CMDLINE_LINUX="rd.lvm.lv=fedora/swap rd.lvm.lv=fedora/root rhgb quiet 
crashkernel=128M"
The size of crashkernel depends on; 
  o Machine Architecture. 
  o Total amount of installed system memory. 
  o [128 MB + 4 bits for every 4KB page]
Step: 3
Rebuild the grub2 configuration file.
# grub2­mkconfig ­o /boot/grub2/grub.cfg
Reboot the system for changes to take effect.
# reboot
Step: 4
Verify the memory reserved for crash/kdump kernel.
# cat /proc/cmdline 
BOOT_IMAGE=/vmlinuz­4.0.4­301.fc22.x86_64 root=/dev/mapper/fedora­root ro 
rd.lvm.lv=fedora/swap rd.lvm.lv=fedora/root rhgb quiet crashkernel=128M
# cat /sys/kernel/kexec_crash_loaded 
1
# cat /sys/kernel/kexec_crash_size 
134217728
Step: 5
Configure the dump target (default is /var/crash )
# vi /etc/kdump.conf
  path /var/crash
Note: 1 
Currently only one dump target and path can be configured at once. 
Note: 2 
The free disk space on the target dump device must be equal to the physical    
memory on the system. 
/etc/kdump.conf
 path <path>           
 o "path" represents the filesystem path in which vmcore will be saved.
 
 path /var/crash
 
 raw <partition>   
 o Use to set dump target to raw <partition>.
 raw /dev/vg/lv_kdump
<fs type> <partition> 
o Use to set dump target to a specific partition of a specific 
filesystem type.
ext4 /dev/vg/lv_kdump
ext4 UUID=03138356­5e61­4ab3­b58e­27507ac41937
/etc/kdump.conf
nfs <nfs mount>       
o Use to set dump target to NFS mount point. 
nfs server.example.com:/export/tmp
ssh <user@server>     
o Used to set dump target on remote machine.
ssh user@server.example.com
Step: 6
Set the message level and dump level to filter the pages from vmcore.
# vi /etc/kdump.conf
 path /var/crash
 core_collector makedumpfile ­l ­­message­level 1 ­d 31
/etc/kdump.conf
core_collector <command> <options>
o This allows you to specify the command to copy the vmcore.
  
core_collector makedumpfile ­c ­­message­level 1 ­d 31
  ­c : Use to compress the vmcore file.
  ­d : Use to set the dump_level.
o "dump_level" is use to decide which pages to be filter from the vmcore file. 
Step: 7
Set the action to preform in case dumping to intended target fails. 
# vi /ect/kdump.conf
path /var/crash
core_collector makedumpfile ­l ­­message­level 1 ­d 31
default reboot
Note: 
If no default action is specified, "reboot" is assumed default.
Step: 8
Enable the kdump service. 
# systemctl enable kdump
Start the kdump service.
# systemctl start kdump.service
# kdumpctl start
Verify kdump service status.
# systemctl status kdump.service
# kdumpctl status
How to test kdump setup ?
Enable magic key "SysRq" to trigger kernel panic.
# echo 1 > /proc/sys/kernel/sysrq 
Trigger SysRq panic event (c) to crash the system.
# echo c > /proc/sysrq­trigger
How to verify kernel crash dump (vmcore) ? 
 Verify /var/crash directory for vmcore and vmcore­dmesg.txt file.
# tree /var/crash/
/var/crash/
 └── 127.0.0.1­2015.06.08­17:25:32
      ├── vmcore
      └── vmcore­dmesg.txt
 Open kernel crash dump (vmcore) using crash utility.
# crash ­­osrelease vmcore
# crash ­d 1 vmcore| egrep "nodename|release|machine|dump_level"
References:
https://www.kernel.org/doc/Documentation/kdump/kdump.txt
https://www.kernel.org/doc/ols/2007/ols2007v1­pages­167­178.pdf
http://people.redhat.com/nhorman/papers/ols­slides.pdf
/usr/share/doc/kexec­tools/kexec­kdump­howto.txt
Questions ?

More Related Content

What's hot

Kernel Recipes 2015: Kernel packet capture technologies
Kernel Recipes 2015: Kernel packet capture technologiesKernel Recipes 2015: Kernel packet capture technologies
Kernel Recipes 2015: Kernel packet capture technologies
Anne Nicolas
 
First steps on CentOs7
First steps on CentOs7First steps on CentOs7
First steps on CentOs7
Marc Cortinas Val
 
Kernel Recipes 2015 - Porting Linux to a new processor architecture
Kernel Recipes 2015 - Porting Linux to a new processor architectureKernel Recipes 2015 - Porting Linux to a new processor architecture
Kernel Recipes 2015 - Porting Linux to a new processor architecture
Anne Nicolas
 
Kernel crashdump
Kernel crashdumpKernel crashdump
Kernel crashdump
Adrien Mahieux
 
kdump: usage and_internals
kdump: usage and_internalskdump: usage and_internals
kdump: usage and_internals
LinuxCon ContainerCon CloudOpen China
 
Containers with systemd-nspawn
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawn
Gábor Nyers
 
Linux con europe_2014_f
Linux con europe_2014_fLinux con europe_2014_f
Linux con europe_2014_f
sprdd
 
Systemd cheatsheet
Systemd cheatsheetSystemd cheatsheet
Systemd cheatsheet
Susant Sahani
 
Kernel Recipes 2015 - Hardened kernels for everyone
Kernel Recipes 2015 - Hardened kernels for everyoneKernel Recipes 2015 - Hardened kernels for everyone
Kernel Recipes 2015 - Hardened kernels for everyone
Anne Nicolas
 
Kernel Recipes 2015: Speed up your kernel development cycle with QEMU
Kernel Recipes 2015: Speed up your kernel development cycle with QEMUKernel Recipes 2015: Speed up your kernel development cycle with QEMU
Kernel Recipes 2015: Speed up your kernel development cycle with QEMU
Anne Nicolas
 
Kdump
KdumpKdump
LCA13: Android Kernel Upstreaming: Overview & Status
LCA13: Android Kernel Upstreaming: Overview & StatusLCA13: Android Kernel Upstreaming: Overview & Status
LCA13: Android Kernel Upstreaming: Overview & Status
Linaro
 
Performance: Observe and Tune
Performance: Observe and TunePerformance: Observe and Tune
Performance: Observe and Tune
Paul V. Novarese
 
QEMU Disk IO Which performs Better: Native or threads?
QEMU Disk IO Which performs Better: Native or threads?QEMU Disk IO Which performs Better: Native or threads?
QEMU Disk IO Which performs Better: Native or threads?
Pradeep Kumar
 
CLUG 2010 09 - systemd - the new init system
CLUG 2010 09 - systemd - the new init systemCLUG 2010 09 - systemd - the new init system
CLUG 2010 09 - systemd - the new init system
PaulWay
 
Kernel Recipes 2015: Introduction to Kernel Power Management
Kernel Recipes 2015: Introduction to Kernel Power ManagementKernel Recipes 2015: Introduction to Kernel Power Management
Kernel Recipes 2015: Introduction to Kernel Power Management
Anne Nicolas
 
How to debug ocfs2 hang problem
How to debug ocfs2 hang problemHow to debug ocfs2 hang problem
How to debug ocfs2 hang problem
Gang He
 
Xen Debugging
Xen DebuggingXen Debugging
Xen Debugging
The Linux Foundation
 
Understanding Linux system hang
Understanding Linux system hangUnderstanding Linux system hang
Understanding Linux system hang
Gang He
 
XPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSE
XPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSEXPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSE
XPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSE
The Linux Foundation
 

What's hot (20)

Kernel Recipes 2015: Kernel packet capture technologies
Kernel Recipes 2015: Kernel packet capture technologiesKernel Recipes 2015: Kernel packet capture technologies
Kernel Recipes 2015: Kernel packet capture technologies
 
First steps on CentOs7
First steps on CentOs7First steps on CentOs7
First steps on CentOs7
 
Kernel Recipes 2015 - Porting Linux to a new processor architecture
Kernel Recipes 2015 - Porting Linux to a new processor architectureKernel Recipes 2015 - Porting Linux to a new processor architecture
Kernel Recipes 2015 - Porting Linux to a new processor architecture
 
Kernel crashdump
Kernel crashdumpKernel crashdump
Kernel crashdump
 
kdump: usage and_internals
kdump: usage and_internalskdump: usage and_internals
kdump: usage and_internals
 
Containers with systemd-nspawn
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawn
 
Linux con europe_2014_f
Linux con europe_2014_fLinux con europe_2014_f
Linux con europe_2014_f
 
Systemd cheatsheet
Systemd cheatsheetSystemd cheatsheet
Systemd cheatsheet
 
Kernel Recipes 2015 - Hardened kernels for everyone
Kernel Recipes 2015 - Hardened kernels for everyoneKernel Recipes 2015 - Hardened kernels for everyone
Kernel Recipes 2015 - Hardened kernels for everyone
 
Kernel Recipes 2015: Speed up your kernel development cycle with QEMU
Kernel Recipes 2015: Speed up your kernel development cycle with QEMUKernel Recipes 2015: Speed up your kernel development cycle with QEMU
Kernel Recipes 2015: Speed up your kernel development cycle with QEMU
 
Kdump
KdumpKdump
Kdump
 
LCA13: Android Kernel Upstreaming: Overview & Status
LCA13: Android Kernel Upstreaming: Overview & StatusLCA13: Android Kernel Upstreaming: Overview & Status
LCA13: Android Kernel Upstreaming: Overview & Status
 
Performance: Observe and Tune
Performance: Observe and TunePerformance: Observe and Tune
Performance: Observe and Tune
 
QEMU Disk IO Which performs Better: Native or threads?
QEMU Disk IO Which performs Better: Native or threads?QEMU Disk IO Which performs Better: Native or threads?
QEMU Disk IO Which performs Better: Native or threads?
 
CLUG 2010 09 - systemd - the new init system
CLUG 2010 09 - systemd - the new init systemCLUG 2010 09 - systemd - the new init system
CLUG 2010 09 - systemd - the new init system
 
Kernel Recipes 2015: Introduction to Kernel Power Management
Kernel Recipes 2015: Introduction to Kernel Power ManagementKernel Recipes 2015: Introduction to Kernel Power Management
Kernel Recipes 2015: Introduction to Kernel Power Management
 
How to debug ocfs2 hang problem
How to debug ocfs2 hang problemHow to debug ocfs2 hang problem
How to debug ocfs2 hang problem
 
Xen Debugging
Xen DebuggingXen Debugging
Xen Debugging
 
Understanding Linux system hang
Understanding Linux system hangUnderstanding Linux system hang
Understanding Linux system hang
 
XPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSE
XPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSEXPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSE
XPDDS19: Core Scheduling in Xen - Jürgen Groß, SUSE
 

Similar to Kdump-FUDcon-2015-Session

kexec / kdump implementation in Linux Kernel and Xen hypervisor
kexec / kdump implementation in Linux Kernel and Xen hypervisorkexec / kdump implementation in Linux Kernel and Xen hypervisor
kexec / kdump implementation in Linux Kernel and Xen hypervisorThe Linux Foundation
 
k8s practice 2023.pptx
k8s practice 2023.pptxk8s practice 2023.pptx
k8s practice 2023.pptx
wonyong hwang
 
Fast boot
Fast bootFast boot
Fast boot
SZ Lin
 
kubernetes practice
kubernetes practicekubernetes practice
kubernetes practice
wonyong hwang
 
Docker Security Paradigm
Docker Security ParadigmDocker Security Paradigm
Docker Security Paradigm
Anis LARGUEM
 
Introducing Docker
Introducing DockerIntroducing Docker
Introducing Docker
Francesco Pantano
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel Development
Priyank Kapadia
 
Lecture 5 Kernel Development
Lecture 5 Kernel DevelopmentLecture 5 Kernel Development
Lecture 5 Kernel Development
Mohammed Farrag
 
Kubernetes installation
Kubernetes installationKubernetes installation
Kubernetes installation
Ahmed Mekawy
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time OptimizationKan-Ru Chen
 
”Bare-Metal Container" presented at HPCC2016
”Bare-Metal Container" presented at HPCC2016”Bare-Metal Container" presented at HPCC2016
”Bare-Metal Container" presented at HPCC2016
Kuniyasu Suzaki
 
Kubernetes laravel and kubernetes
Kubernetes   laravel and kubernetesKubernetes   laravel and kubernetes
Kubernetes laravel and kubernetes
William Stewart
 
kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...
kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...
kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...
ssuser92b4be
 
Rloader, alternative tech to achieve fast boot time for ARM Linux
Rloader, alternative tech to achieve fast boot time for ARM LinuxRloader, alternative tech to achieve fast boot time for ARM Linux
Rloader, alternative tech to achieve fast boot time for ARM Linux
matt_hsu
 
青云CoreOS虚拟机部署kubernetes
青云CoreOS虚拟机部署kubernetes 青云CoreOS虚拟机部署kubernetes
青云CoreOS虚拟机部署kubernetes
Zhichao Liang
 
Medooze MCU Video Multiconference Server Installation and configuration guide...
Medooze MCU Video Multiconference Server Installation and configuration guide...Medooze MCU Video Multiconference Server Installation and configuration guide...
Medooze MCU Video Multiconference Server Installation and configuration guide...sreeharsha43
 
Yocto Project Dev Day Prague 2017 - Advanced class - Kernel modules with eSDK
Yocto Project Dev Day Prague 2017 - Advanced class - Kernel modules with eSDKYocto Project Dev Day Prague 2017 - Advanced class - Kernel modules with eSDK
Yocto Project Dev Day Prague 2017 - Advanced class - Kernel modules with eSDK
Marco Cavallini
 
From zero to Docker
From zero to DockerFrom zero to Docker
From zero to Docker
Giovanni Toraldo
 
What is this "docker"
What is this  "docker" What is this  "docker"
What is this "docker"
Jean-Marc Meessen
 

Similar to Kdump-FUDcon-2015-Session (20)

kexec / kdump implementation in Linux Kernel and Xen hypervisor
kexec / kdump implementation in Linux Kernel and Xen hypervisorkexec / kdump implementation in Linux Kernel and Xen hypervisor
kexec / kdump implementation in Linux Kernel and Xen hypervisor
 
k8s practice 2023.pptx
k8s practice 2023.pptxk8s practice 2023.pptx
k8s practice 2023.pptx
 
Fast boot
Fast bootFast boot
Fast boot
 
kubernetes practice
kubernetes practicekubernetes practice
kubernetes practice
 
Docker Security Paradigm
Docker Security ParadigmDocker Security Paradigm
Docker Security Paradigm
 
Introducing Docker
Introducing DockerIntroducing Docker
Introducing Docker
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel Development
 
Lecture 5 Kernel Development
Lecture 5 Kernel DevelopmentLecture 5 Kernel Development
Lecture 5 Kernel Development
 
Kubernetes installation
Kubernetes installationKubernetes installation
Kubernetes installation
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
 
”Bare-Metal Container" presented at HPCC2016
”Bare-Metal Container" presented at HPCC2016”Bare-Metal Container" presented at HPCC2016
”Bare-Metal Container" presented at HPCC2016
 
Kubernetes laravel and kubernetes
Kubernetes   laravel and kubernetesKubernetes   laravel and kubernetes
Kubernetes laravel and kubernetes
 
kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...
kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...
kubeadm Cluster Creation Internals_ From Self-Hosting to Upgradability and HA...
 
Rloader, alternative tech to achieve fast boot time for ARM Linux
Rloader, alternative tech to achieve fast boot time for ARM LinuxRloader, alternative tech to achieve fast boot time for ARM Linux
Rloader, alternative tech to achieve fast boot time for ARM Linux
 
青云CoreOS虚拟机部署kubernetes
青云CoreOS虚拟机部署kubernetes 青云CoreOS虚拟机部署kubernetes
青云CoreOS虚拟机部署kubernetes
 
Medooze MCU Video Multiconference Server Installation and configuration guide...
Medooze MCU Video Multiconference Server Installation and configuration guide...Medooze MCU Video Multiconference Server Installation and configuration guide...
Medooze MCU Video Multiconference Server Installation and configuration guide...
 
Lab docker
Lab dockerLab docker
Lab docker
 
Yocto Project Dev Day Prague 2017 - Advanced class - Kernel modules with eSDK
Yocto Project Dev Day Prague 2017 - Advanced class - Kernel modules with eSDKYocto Project Dev Day Prague 2017 - Advanced class - Kernel modules with eSDK
Yocto Project Dev Day Prague 2017 - Advanced class - Kernel modules with eSDK
 
From zero to Docker
From zero to DockerFrom zero to Docker
From zero to Docker
 
What is this "docker"
What is this  "docker" What is this  "docker"
What is this "docker"
 

Kdump-FUDcon-2015-Session