Kexec and Kdump on arm64
Kexec is a tool to boot another kernel image from the current one. So that you can have a faster system reboot without having to do any of the hardware initialization. This can be used in case of a system crash as well.
Kdump is a dump capturing tool. kexec can be used to effectively to dump the kernel and core states in case of a system crash.
Version information
verified with version 2.0.17.
getting the sources:
wget https://mirrors.edge.kernel.org/pub/linux/utils/kernel/kexec/kexec-tools-2.0.17.tar.gz
The kexec sources have kdump sources also. So don’t have to download kdump sources.
Note: The versions 2.0.10 and below don’t have arm64 support.
Compiling the sources
Native compilation did not work for me. Below are the steps for cross compilation.
tar xvzf kexec-tools-2.0.17.tar.gz
cd kexec-tools-2.0.17
./configure --build=x86_64-linux --host=aarch64-unknown-linux-gnu --target=aarch64-unknown-linux-gnu
make ARCH=arm64 clean all
make install
Run the binaries
system kernel configuration
in make menuconfig while compiling the kernel, enable the below listed items
CONFIG_KEXEC=y
CONFIG_SYSFS=y
CONFIG_DEBUG_INFO=Y
Add crashkernel=0M-2G:128M,2G-6G:256M,6G-8G:512M,8G-:768M to bootargs
The crashkernel bootargs has to be supplied based on the amount of ram available. Can find more details about crashkernel bootargs in the below link
crash kernel/dump-capture kernel configuration
CONFIG_CRASH_DUMP=y
CONFIG_PROC_VMCORE=y
Load the Dump-capture Kernel
kexec -p <dump capture kernel path> — append=”`cat /proc/cmdline` reset_devices”
The kernel image gets booted on crash. For testing purpose you can create a crash with the following command.
echo c > /proc/sysrq-trigger
Write Out to the Dump File
After the dump-capture kernel is booted, write out the dump file with the following command:
cp /proc/vmcore <dump-file>
Misc
You can place the kexec command in the do_stop function of script /etc/init.d/reboot so that the secondary kernel boots in on reboot.