Restart Ubuntu faster with kexec

by Stephen Fluin 2010.01.20

One of the longest and most time consuming parts of the bootup process for any computer is the fact that the default reboot process completely turns off the computer, and returns the CPU to the very first startup task, the BIOS. BIOS initialization and POST does a lot of steps involving test and hardware detection and initialization. When rebooting the computer, this doesn't really add any value, as these devices have already been detected and had their first initialization done.

This is where kexec comes in. kexec is a tool that allows Ubuntu (or any Linux distribution) to pass control between kernels directly. This means that when rebooting, control never get's passed back to the BIOS for reboot, and no additional device testing or detection (beyond that required by linux) needs to be done. For me, all of the initialization steps in the BIOS and GRUB before Linux takes over takes around 30-40 seconds. This is a little bit longer than the average case, but I'm sure this is a problem for a lot of people.

How to install kexec

You can install kexec in Ubuntu using the following command:

sudo apt-get install kexec

The installation will ask you if you want to replace the reboot process. In order to have the benefits of skipping unnecessary steps in reboot, you need to choose the option that uses kexec for your reboot.

What could go wrong?

The only problem with this is when you are attempting to actually return to the BIOS, or if you want to go back to GRUB to choose another operating system in the case where you dual boot. This isn't that big of a deal though. Although I haven't found a way to pass control directly to GRUB or back to the BIOS, it is possible just to choose shutdown, and then turn the computer back on after the shutdown has completed. It doesn't take any extra time, it just takes more effort as you need to press the power button on the computer.