GRUB has a cool functionality to try booting from a different kernel entry if the default one fails. This will be more helpful when we only have SSH access to the server and need to update/change the kernel. We can configure this on the grub menu using configuration directive “fallback”.

Following is a sample grub.confconfiguration for fallback option,

———————————————————————–
|default saved |
|timeout=10 |
|fallback 1 2 |
| |
|title Newly_installed Kernel |
|root (hd0,0) |
|kernel /vmlinuz-2.6.32-279.22.1.el6.x86_64 ro root=/dev/sda1 panic=5 |
|initrd /initramfs-2.6.32-279.22.1.el6.x86_64.img |
|savedefault fallback |
| |
|title Current Kernel |
|root (hd0,0) |
|kernel /vmlinuz-2.6.32-264.22.1.el6.x86_64 ro root=/dev/sda1 panic=5 |
|initrd /initramfs-2.6.32-264.22.1.el6.x86_64.img |
|savedefault fallback |
| |
|title Backup Kernel |
|root (hd0,0) |
|kernel /vmlinuz-2.6.32-254.22.1.el6.x86_64 ro root=/dev/sda1 |
|initrd /initramfs-2.6.32-254.22.1.el6.x86_64.img |
|initrd /initrd-2.6.18-194.8.1.el5.img |
|savedefault |
———————————————————————–

The configuration should start with “default saved” instead of an entry number, while using this the default entry will be the saved one with “savedefault” directive. “savedefault” entry will save the last successfully booted kernel. When we use “savedefault fallback” it will save the next boot entry number as next default,ie, on first boot (entry number 0) it will set the next default entry as 1 and if it fails the next default entry will be 2.

“fallback 1 2” tellssavedefaultto set 1 as next boot entry and then 2. If the system fails to boot “panic=5” will reboot the system after 5 seconds.

The above configuration will try to boot from the Newly_installed, Current and Backup respectively.

Happy Kernel Upgrade:)