As mentioned above, using kexec consists of (1) loading the kernel to be rebooted to into memory, and (2) actually rebooting to it. To load a kernel, the syntax is as follows:

kexec -l <kernel-image> --append="<command-line-options>"

where <kernel-image> is the kernel file that you intend to reboot to and <command-line-options> contain the command-line parameters that need to be passed to the new kernel. Because the wrong command-line options can cause problems during the reboot, passing the contents of /proc/cmdline is the safest way to ensure that legal values are passed to the rebooting kernel.

For example, if the kernel image you want to reboot is /boot/bzImage, and the contents of /proc/cmdline are "root=/dev/hda1", the command to load the kernel would be:

kexec -l /boot/bzImage -append="root=/dev/hda1"

Then, to actually reboot to the loaded kernel, just type:

kexec -e

The system will reboot immediately. Unlike the normal reboot process, kexec does not perform a clean shutdown of the system before rebooting. It is left to you to kill all applications and unmount file systems before attempting a kexec reboot.

About the author
Hariprasad Nellitheertha works in the Linux Technology Center at IBM India Software Labs, Bangalore. Hari currently works on the LKCD (Linux Kernel Crash Dumps) project, and previously worked on OS/2 kernel and file systems. Contact Hari at nharipra@in.ibm.com.

_________________# emerge -C gelmini

Last edited by codadilupo on Fri Jul 23, 2004 9:52 am; edited 2 times in total