When you test a new kernel or a new OS, it is important to make sure that your computer can boot even if the new system is unbootable. This is crucial especially if you maintain servers or remote systems. To accomplish this goal, you need to set up two things:

You must maintain a system which is always bootable. For instance, if you test a new kernel, you need to keep a working kernel in a different place. And, it would sometimes be very nice to even have a complete copy of a working system in a different partition or disk. You must direct GRUB to boot a working system when the new system fails. This is possible with the fallback system in GRUB. The former requirement is very specific to each OS, so this documentation does not cover that topic. It is better to consult some backup tools.

Fallback

GRUB supports a fallback mechanism of booting one or more other entries if a default boot entry fails. You can specify multiple fallback entries if you wish.

Suppose that you have three systems, A', B' and C'. A' is a system which you want to boot by default. B' is a backup system which is supposed to boot safely. C' is another backup system which is used in case where `B' is broken.

Then you may want GRUB to boot the first system which is bootable among A', B' and `C'. A configuration file can be written in this way:

     default saved        # This is important!!!
     timeout 10
     fallback 1 2         # This is important!!!
     
     title A
     root (hd0,0)
     kernel /kernel
     savedefault fallback # This is important!!!
     
     title B
     root (hd1,0)
     kernel /kernel
     savedefault fallback # This is important!!!
     
     title C
     root (hd2,0)
     kernel /kernel
     savedefault

Note that default saved' (see ["default"]), fallback 1 2' and `savedefault fallback' are used. GRUB will boot a saved entry by default and save a fallback entry as next boot entry with this configuration.

When GRUB tries to boot A', GRUB saves 1' as next boot entry, because the command fallback specifies that 1' is the first fallback entry. The entry 1' is B', so GRUB will try to boot B' at next boot time.

Likewise, when GRUB tries to boot B', GRUB saves 2' as next boot entry, because fallback specifies 2' as next fallback entry. This makes sure that GRUB will boot C' after booting `B'.

It is noteworthy that GRUB uses fallback entries both when GRUB itself fails in booting an entry and when A' or B' fails in starting up your system. So this solution ensures that your system is started even if GRUB cannot find your kernel or if your kernel panics.

However, you need to run grub-set-default when A' starts correctly or you fix A' after it crashes, since GRUB always sets next boot entry to a fallback entry. You should run this command in a startup script such as rc.local to boot `A' by default:

     # grub-set-default 0

where 0' is the number of the boot entry for the system A'.

If you want to see what is current default entry, you can look at the file /boot/grub/default (or /grub/default in some systems). Because this file is plain-text, you can just cat this file. But it is strongly recommended not to modify this file directly, because GRUB may fail in saving a default entry in this file, if you change this file in an unintended manner. Therefore, you should use grub-set-default when you need to change the default entry.


CategoryDocumentation CategoryObsolete

GrubWiki: RobustSystem (last edited 2008-05-16 19:24:39 by VesaJääskeläinen)