Next: , Up: Making your system robust

4.3.1 Booting once-only

You can teach GRUB to boot an entry only at next boot time. Suppose that your have an old kernel old_kernel and a new kernel new_kernel. You know that old_kernel can boot your system correctly, and you want to test new_kernel.

To ensure that your system will go back to the old kernel even if the new kernel fails (e.g. it panics), you can specify that GRUB should try the new kernel only once and boot the old kernel after that.

First, modify your configuration file. Here is an example:

     default saved        # This is important!!!
     timeout 10
     title the old kernel
     root (hd0,0)
     kernel /old_kernel
     title the new kernel
     root (hd0,0)
     kernel /new_kernel
     savedefault 0         # This is important!!!

Note that this configuration file uses `default saved' (see default) at the head and `savedefault 0' (see savedefault) in the entry for the new kernel. This means that GRUB boots a saved entry by default, and booting the entry for the new kernel saves `0' as the saved entry.

With this configuration file, after all, GRUB always tries to boot the old kernel after it booted the new one, because `0' is the entry of the old kernel.

The next step is to tell GRUB to boot the new kernel at next boot time. For this, execute grub-set-default (see Invoking grub-set-default):

     # grub-set-default 1

This command sets the saved entry to `1', that is, to the new kernel.

This method is useful, but still not very robust, because GRUB stops booting, if there is any error in the boot entry, such that the new kernel has an invalid executable format. Thus, it it even better to use the fallback mechanism of GRUB. Look at next subsection for this feature.