Friday, October 5, 2012

Rebooting quickly in Fedora with kexec

If you're like me and you want to reboot quickly and avoid bios POST or other startup routines, kexec can be used to achieve this by skipping everything before the bootloader.

Install kexec-tools , regenerate your initramfs with dracut (so you can pull in the new bits, if you've never had kexec installed before), and then make a shortcut like this:


[root@tronik-laptop ~]# more readykexec.sh
cmdline=`cat /proc/cmdline` ; krnl=`uname -r` ; kexec -l /boot/vmlinuz-$krnl --i
nitrd=/boot/initramfs-"$krnl".img --reuse-cmdline

You can then run readykexec.sh and reboot to reload your current kernel (or any other kernel you happen to want to use.)

If you don't regenerate with dracut before trying to use kexec you will receive an error in the shell that kexec cannot be found.

Tested this in Fedora 17 and Fedora 18.