kexec
Reboot quickly into another kernel
TLDR
Load a new kernel
Load a new kernel with current boot parameters
Execute a currently loaded kernel
Unload current kexec target kernel
SYNOPSIS
kexec [-l|--load <kernel>] [options] [--append=<cmdline>] [--initrd[=<file>]]
kexec -u|--unload
kexec -e|--exec
kexec -i|--status
PARAMETERS
-l, --load <kernel>
Load kernel image into memory (default action)
-u, --unload
Unload previously loaded kernel from memory
-e, --exec
Execute the loaded kernel (reboot directly)
-p, --preserve-context
Preserve user memory mappings and context
-i, --initrd=<file>
Specify initramfs/initrd image
-a, --append=<cmdline>
Append kernel command line parameters
--dtb=<dtb>
Load device tree blob for ARM/PowerPC
--kexec-on-panic[=<path>]
Auto-load for panic kernel (kdump)
--noefi
Disable EFI runtime services usage
-d, --debug
Enable debug output
-i, --status
Show status of loaded kernel
-v, --version
Display version information
-h, --help
Show help
DESCRIPTION
kexec is a system utility in Linux that enables loading and booting a new kernel image directly from the currently running kernel, bypassing the traditional bootloader and BIOS/UEFI firmware. This results in significantly faster reboots, often in seconds, and is crucial for kernel crash dumping with kdump.
Using the kexec system call (kexec_load(2)), it copies the new kernel, optional initramfs, and device tree blob into reserved memory. The -l option loads the image, -e executes it, and -u unloads. It's commonly used in production for quick kernel updates, testing, or capturing vmcore dumps during panics via /proc/sys/kernel/kexec_load_disabled and kexec_on_panic.
Requires root privileges (CAP_SYS_BOOT) and kexec-tools package. On EFI systems, secure boot may interfere. Misuse can lead to unbootable systems, so backups are essential. Supports purgatory code for memory protection and type-specific loading (e.g., bzImage, ELF).
CAVEATS
Requires root and CAP_SYS_BOOT; can brick system with invalid kernel; EFI/Secure Boot issues; not for regular useātest thoroughly; disables watchdog during load.
SECURITY
Kernel parameter kexec_load_disabled=1 blocks loading if set; use sysctl to toggle. Purgatory validates images.
EXAMPLE
Load: kexec -l /boot/vmlinuz-new --initrd=/boot/initrd-new.img --append='root=/dev/sda1 console=ttyS0'
Exec: kexec -e
HISTORY
Developed by Eric Biederman in 2003 for Linux 2.6; integrated into mainline kernel ~2.6.13; kexec-tools package maintained by coreos; enhanced for EFI, ARM, crash dumping (kdump since 2.6.20).


