Shortening reboot times with kexec - TAM Tip

Latest response

 

Hi all,

 

I just thought I'd share this great performance tip from one of our Technical Account Managers (TAMs):

 

Have you ever been fustrated by long reboot times when doing things like testing with different kernels, configurations, and so on?

The system just takes too long to restart in the BIOS!

 

Here comes kexec to the rescue!

 

How does that work? First you load the kernel that you want to boot and keep it in memory. You can just load it and leave it ready to restart. When your system is told to restart, after stopping and unmounting stuff, instead of restarting and going to BIOS tests, init will call kexec and start the kernel load, shortening your reboot time.

How to use it:

 

A. Specifying a specific kernel, initrd & cmdline:

# kexec -l /boot/vmlinuz- --initrd=/boot/ \
--append=$cmdline

 

B. Using current kernel:

B.1) For RHEL5:

# cmdline=`cat /proc/cmdline` ; krnl=`uname -r` ; \
kexec -l /boot/vmlinuz-$krnl --initrd=/boot/initrd-"$krnl".img \
--append=$cmdline

B.2) For RHEL6:

# krnl=`uname -r` ; kexec -l /boot/vmlinuz-$krnl \
--initrd=/boot/initramfs-"$krnl".img --reuse-cmdline 

 

 

C. And then, restart your system:

# reboot

Just after the system shuts down, the new kernel will be immediately loaded!   

 

If you've got any useful tips, don't hesitate to share them with the community!

Responses