Kexec

Kexec is a system call that enables you to load and boot into another kernel from the currently running kernel. This is useful for kernel developers or other people who need to reboot very quickly without waiting for the whole BIOS boot process to finish. Note that kexec may not work correctly for you due to devices not fully re-initializing when using this method, however this is rarely the case.

Systemd

By default, if systemd-boot is used and no kernel was loaded manually using kexec -l before, systemd will load the kernel specified in the default boot loader entry. For example, to reboot into the newer kernel after a system update, you may simply run:

# systemctl kexec

The command will refuse to execute if you have several initrd entries (e.g. for Microcode updates) which are currently not supported.

Custom unit file

If the default behavior does not work for you or you desire to conveniently load custom kernels, you may wrap the kernel loading into a service unit. Create a new unit file, kexec-load@.service, that will load the specified kernel to be kexec'ed:

Ensure that the shutdown hook is not part of your initramfs image by removing it from the HOOKS array in /etc/mkinitcpio.conf. If it is, remove it and rebuild your initrd image with mkinitcpio -p linux.

Then to kexec

# systemctl kexec

If you wish to load a different kernel for the next kexec, for example linux-lts, disable the service for the current kernel and enable the one for the new kernel:

Separate /boot partition

The above systemd unit file will fail if /boot is not on the root file system, as systemd will likely unmount /boot before it runs the kexec-load unit file. An alternative approach is to load a "hook" unit file that does nothing on startup and invokes kexec upon termination. By making this unit file conflict with kexec.target and only kexec.target, you can ensure the new kernel gets loaded early enough and only after a "systemctl kexec" command. Here is an alternate /etc/systemd/system/kexec-load@.service file that follows this strategy:

Troubleshooting

System hangs or reboots after "kexec_core: Starting new kernel"

In particular, if adding the acpi=off kernel parameter makes kexec work correctly, adding the acpi_rsdp kernel parameter on the kexec command line as explained in [1] may solve the issue in some cases without the need to completely disable ACPI.