kexec
Kexec is a command line tool that provides a way to boot into a new kernel from the currently running kernel, without going through a complete system reboot. It is available in most Linux distributions and is often used for debugging purposes or to quickly change between different kernels.
Using kexec, you can load a new kernel and its associated initramfs (initial RAM file system) directly into memory, bypassing the BIOS or UEFI firmware. This allows for faster kernel switching and reduces the downtime required for rebooting.
Kexec also provides an option to preserve some part of the current kernel's state, such as loaded kernel modules, and transfer it to the new kernel, ensuring a smooth transition. This feature is particularly useful for kernel developers or system administrators who frequently experiment with different kernel configurations.
Kexec utilizes the kexec system call, which is an interface between the kernel and user space, to unload the current kernel and load the new one. It may require root or administrator privileges to execute the kexec command successfully.
It is important to note that kexec does not perform a full system initialization like a regular boot process. It directly starts executing the new kernel, which means any existing user space processes or services will not be restarted automatically. Therefore, it is crucial to ensure all necessary system initialization steps are performed before using kexec, or manually restarting any required services after the kernel switch.
List of commands for kexec:
-
kexec:tldr:0c3b2 kexec: Load a new kernel with current boot parameters.$ kexec -l ${path-to-kernel} --initrd=${path-to-initrd} --reuse-cmdlinetry on your machineexplain this command
-
kexec:tldr:301c3 kexec: Load a new kernel.$ kexec -l ${path-to-kernel} --initrd=${path-to-initrd} --command-line=${arguments}try on your machineexplain this command
-
kexec:tldr:4d212 kexec: Unload current kexec target kernel.$ kexec -utry on your machineexplain this command
-
kexec:tldr:bfc8a kexec: Execute a currently loaded kernel.$ kexec -etry on your machineexplain this command