Here, I’m illustrating with kernels A, B and C. A is the new kernel, B and C are older kernels. The grub.conf reads the first kernel entry as 0.
First the server checks the kernel A, if the server isn’t booting with that kernel it’ll try loading kernel B. If B fails to load, then it’ll load kernel C.
These are the entries that we need in the /etc/grub.conf file to have kernel fallback.
default saved timeout 10 fallback 1 2 title A kernel /boot/vmlinuzx root (hd0,1) initrd /boot/initramfs-x.img savedefault fallback title B kernel /boot/vmlinuzx root (hd0,1) initrd /boot/initramfs-x.img savedefault fallback title C kernel /boot/vmlinuzx root (hd0,1) initrd /boot/initramfs-x.img savedefault
By default, grub will load the “default saved” entry and will save a fallback entry as next boot entry with this configuration.
That is, when Grub tries to boot “A”, it will save 1 which is “B” as the next boot entry as the command specifies that 1 is the first fallback entry.
Similarly, when Grub tries to boot B, it saves 2 “C” as the next boot entry as fallback specifies 2 as the next boot entry.