If you’re dual booting Ubuntu with other Linux distributions or Windows, you may wish to change the which operating system starts by default. Ubuntu uses the GRUB boot loader to display a menu of installed operating systems and boot them. If you don’t see the menu before Ubuntu starts, hold down the shift key while your system starts up.

This guide is intended for Ubuntu 11.04 and 11.10, which both use GRUB version 1.99. If you’ve upgraded from an older Ubuntu installation, you may still have an older version of GRUB. Search in Ubuntu Software Center for grub-pc and check the version if you’re not sure.

There’s a graphical configuration tool for GRUB called StartUp-Manager. Unfortunately, judging by its reviews in Ubuntu Software Center the application has not been updated for the latest version of GRUB and has some problems. But if you’re comfortable with editing a configuration file and running some terminal commands it’s not difficult to change the default operating system manually.

a GRUB menu with Ubuntu and Windows

GRUB can be configured using the /etc/default/grub file. Before you make any changes to it, it may be a good idea to back it up by creating a copy:
sudo cp /etc/default/grub /etc/default/grub.bak

You can restore the copying the backup over the original:
sudo cp /etc/default/grub.bak /etc/default/grub

Open the file using the text editor with root privileges:
gksu gedit /etc/default/grub

The line GRUB_DEFAULT=0 means that GRUB will select the first menu item to boot. Change this to GRUB_DEFAULT=saved . This change will make it easier to change the default item later.

Save and close the file. Run this command to apply your changes to GRUB’s configuration:
sudo update-grub

The configuration change we made allows the grub-set-default and grub-reboot commands to be used at any time. These allow you to change the default boot item permanently or only for the next boot, respectively.

Run grub-set-default or grub-reboot (with sudo) with the number of the menu item to boot (the first item is 0). This command will change the default to the second item:
sudo grub-set-default 1

In the screenshot above, Windows Vista is menu item 5. If you want to select an item from a submenu like Previous Linux Versions, you can specify the position in the main menu, followed by a greater-than sign (>), followed by the position in the submenu. You can also name an entry instead of giving its position. There’s a great Ubuntu Forums post about how this works. The Ubuntu Wiki also has more details on configuring GRUB.


Related Posts