Thursday, January 5, 2012

How to change the boot sequence in Grub2 (Gnome3, Fedora 16 and Ubuntu 11.10/10.00)


The new Gnome3 based Linux distributions (Fedora 16 and Ubuntu 12.04) are now coming with gurub2 boot loader package. The GRUB2 is rather different and a tad bit complex than the legacy GRUB loader. For example among other feature in GRUB2 the boot menu is created by reading multiple scripts present in /etc/grub.d/ directory and the /etc/default/grub file.

To make windows as a default operating system I've compressed the lengthy boot sequence changing procedure into these three simple steps.
  • Login in as root
  • Edit  /etc/default/grub
    Change GRUB_DEFAULT= (sequence number your OS of choice- 1)
    i.e. if windows7 is the 4th option, change the value to 3.

    For example, on my machine to make windows 7 as default OS I changed “GRUB_DEFAULT=saved” to “GRUB_DEFAULT=4

    GRUB_TIMEOUT can also be changed to a lower value, like 1 or 2 seconds to make boot process faster.
  • After changing save the file and run the following script, (exactly as it is) to regenerate the grub boot file with new parameters.
    #grub2-mkconfig -o /boot/grub2/grub.cfg
  • #reboot (Reboot to confirm if it works all right)

Make sure the default menu option is selected correctly, if not count the windows 7 entry and retry the above procedure.

The method has been tested on Fedora-16 + gnome-3. It should also work in Ubuntu/Kubuntu.

If you simply want to update grub2, and you are able to boot into Linux, then you can run the command:
#sudo update-grub
It will rebuild your grub config, finding all the available bootable partitions.

Please comment if you run into issue.

Cheers!