Gentoo Wiki


This article is part of the Tips & Tricks series.
Terminals / Shells Network X Window System Portage System Filesystems Kernel Other


What is kexec?

From the kernel help:

kexec is a system call that implements the ability to shutdown your current kernel, and to start another kernel. It is like a reboot but it is independent of the system firmware. And like a reboot you can start any kernel with it, not just Linux.

The name comes from the similarity to the exec system call.

Basically, a software reboot (you won't need to go through POST/other BIOS stuff).

What you need

Check if you'll need a newer kernel with uname -r. If you've got a kernel that's 2.6.12 or older, you'll need to upgrade it. For instructions on how to do that, follow this guide. Got 2.6.13 or above? Good, follow on.

Getting necessary packages

Run emerge to install kexec as usual: emerge -av kexec-tools

Kernel configuration

You will need to have kexec support enabled:

Linux Kernel Configuration: >=kernel-sources-2.6.13
Processor type and features --->
 [*] kexec system call (EXPERIMENTAL)

Save and exit, build, install, reboot. Not necessary if your current running kernel already has kexec support.

Configuring kexec

You will need to edit /etc/conf.d/kexec. In this file, KNAME is the filename of the kernel you wish to use (ie. KNAME="vmlinuz-2.6.18-gentoo-r1"). The other options should be self explanatory.

Init script

/etc/init.d/kexec is used to load the kernel you specified into memory. You can either add it to a runlevel:

rc-update add kexec boot

or just start it before 'rebooting' into a new kernel:

/etc/init.d/kexec start

Try it out

Now just reboot, what ever way you feel most like doing it:


Rebooting the normal way

If you want to reboot the normal way (for instance, to switch to another kernel or another OS) you'll have to disable the kexec daemon before rebooting.

Do this by logging in as root, and issuing the following command:

/etc/init.d/kexec stop

You will get a few lines of output indicating the success (hopefully) of the command, amongst which should be the following:

 * Not rebooting, so disabling

After this is done, you can reboot without kexec being called, and you will be taken through the POST screens again.

See also

Retrieved from ""

Last modified: Sat, 13 Sep 2008 22:11:00 +0000 Hits: 20,960