During the recent upgrade to 2.6.19 kernel, I ran into a problem with SATA drives. Looks like these options have been brought into a new area of the .config. Not a problem, simple search in the Gentoo forums pointed me in the area where they’re located and I was quickly back in action.
But, it got me to to think about a way to roll back the kernel in case of kernel panics. I have several remote servers where this error would have hurt me badly. Assuming that I could have had a tech reboot the machine and manually select the old kernel I could have been down for hours (not good).
During the recent upgrade to 2.6.19 kernel, I ran into a problem with SATA drives. Looks like these options have been brought into a new area of the .config. Not a problem, simple search in the Gentoo forums pointed me in the area where they’re located and I was quickly back in action.
But, it got me to to think about a way to roll back the kernel in case of kernel panics. I have several remote servers where this error would have hurt me badly. Assuming that I could have had a tech reboot the machine and manually select the old kernel I could have been down for hours (not good).
So, after doing some Googling, I’ve come across a few techniques on how to do this with grub.
The first thing to do (and you must do this again, if you’ve rolled back due to panic) is to use grub-set-default. This is part of the grub suite of tools. Simple run the following command to let grub know to boot with the first kernel in the config.
grub-set-default 0
Next we must edit the /boot/grub/grub.con
default saved
timeout 5
fallback 1
splashimage=(hd0,0)/grub/splash.xpm.gz
Notice ‘default saved’ and ‘fallback 1’. This will let grub know to fallback to the second kernel configuration.
Below is my stripped down grub.conf with kernels.
title=bzImage-2.6.19-gentoo-r5 (sda)
root (hd0,0)
kernel (hd0,0)/bzImage-2.6.19-gentoo-r5 ro root=/dev/md2 panic=10
savedefault fallback
title=bzImage-2.6.18-gentoo-r6 (sda)
root (hd0,0)
kernel (hd0,0)/bzImage-2.6.18-gentoo-r6 ro root=/dev/md2
savedefault
With the panic=10 kernel option, it will reboot on a kernel panic and fallback to the second kernel configuration.
Hope this helps!