04 Nov 2008
Since the 2.6 Linux kernel version came out there is a new way to reboot quite fast. Kexec is a new call system who replaces the running kernel with a new one without the need to go through the bios initialization process. It means than now you’re able to reboot faster, taking away 20, 30 or even 60 seconds from the boot process.
To use it, the “kexec-tools” package must be installed and the option “CONFIG_KEXEC” enabled, after setting up the system, kexec can be used this way:
$ kexec -l /boot/vmlinuz --command-line="`cat /proc/cmdline`" --initrd=/boot/initrd $ kexec -e
The first line loads the kernel in memory and returns the control to the user, it’s now up to you to decide when to “reboot” the system (the second line will do it), some persons are already using this technique to load new kernels when the running one panics.
In the current upstream implementation, kexec doesn’t auto unmount the plugged devices, so it’s must be done manually:
$ kexec -l /boot/vmlinuz --command-line="`cat /proc/cmdline`" --initrd=/boot/initrd $ sync $ umount -a $ kexec -e
Fortunately the Debian/Ubuntu maintainers had already integrated this logic on the reboot/halt scripts and therefore it’s now possible to reboot the system without unmounting anything:
$ kexec -l /boot/vmlinuz --command-line="`cat /proc/cmdline`" --initrd=/boot/initrd $ shutdown -r now
In OpenSuse 11.1 kexec may even be an opt-in. The day where I never shutdown my computer gets closer.