kexec command is used in Linux to boot into a new kernel from the currently running kernel. It allows you to load and execute a new kernel image without rebooting the system. This is useful for testing new kernels or loading a kernel with different parameters without having to go through the entire boot process.
kexec command requires root privileges to execute. To use
kexec, you need to have a new kernel image available on your system. You can download a new kernel from the official Linux kernel website or from your distribution’s package manager.
Once you have a new kernel image, you can use the following command to load and execute it:
sudo kexec -l /path/to/new/kernel sudo kexec -e
The first command loads the new kernel image into memory, and the second command executes it. Note that the
-l option is used to specify the location of the new kernel image, and the
-e option is used to execute it.
You can also pass additional parameters to the new kernel using the
--append option. For example:
sudo kexec -l /path/to/new/kernel --append="root=/dev/sda1" sudo kexec -e
This command loads the new kernel image and passes the
root=/dev/sda1 parameter to it.
The following table lists all available options for the
||Force the kernel to reboot even if it detects errors during the loading process.|
||Load the new kernel image into memory.|
||Execute the new kernel image.|
||Specify the protocol to use for loading the new kernel image.|
||Pass additional parameters to the new kernel image.|
||Use a soft reboot instead of a hard reboot.|
||Halt the system instead of rebooting it.|
||Unload the currently loaded kernel image.|
- Make sure you have the necessary privileges to execute the
kexeccommand. You need to be logged in as root or use the
- If the new kernel image fails to load, try using the
-foption to force a reboot.
- If the system fails to boot after executing the new kernel image, try passing different parameters using the
kexeccommand is not a replacement for a full system reboot. It should only be used for testing purposes or for loading a new kernel with different parameters.
kexeccommand may not work on all systems. It is recommended to test it on a non-production system before using it in a production environment.