How to change the default OS in an Ubuntu dual-boot setup

The GNU Grand Unified Bootloader, a.k.a. GRUB. The GRUB boot menu is a familiar sight to anyone who dual boots.

The boot menu for the GNU Grand Unified Bootloader, a.k.a. GRUB. The menu is a familiar sight to anyone who dual-boots.

Although Linux is great, there are still reasons to keep Windows hanging around on your hard drive. Maybe you can’t live without iTunes for your iPhone/iPod, or perhaps you’re a gamer and still want to play titles that aren’t available on Linux yet. Whatever the reason, dual-booting is a reality that many of us live with.

Ubuntu installs a bootloader called GRUB that allows you to choose which OS you’d like to boot when you start your PC. You’ve probably noticed that Ubuntu is the default OS that boots after you install it in a dual-boot setup. By default, GRUB is configured to automatically boot Ubuntu after 10 seconds, giving you the opportunity to boot into Windows if you so desire.

However, if you want to boot Windows by default, you can easily change GRUB’s default behavior. You can also change GRUB’s timeout length if you simply don’t want to sit around for an additional 10 seconds each time your computer boots. It involves a little under-the-hood tinkering, but by following the steps in this guide, you should be able to change the appropriate settings in just a few minutes.

#1: Determine the order of the OS you’d like to boot in GRUB

Restart your computer. When it boots again, press one of the directional keys (up or down) when the GRUB menu appears. Write down the line number of the OS you’d like to boot. Note: GRUB labels its lines starting with 0, so an OS that’s located on the fifth line would actually be 4.

#2: Open the GRUB config file using the terminal

This may sound intimidating, but it’s not. Boot into Ubuntu and launch a terminal session (open the Dash and type “terminal,” then press Enter). At the command prompt, type the following and press Enter (or, copy-and-paste it into the terminal with Ctrl-Shift-V):

sudo gedit /etc/default/grub

You should be prompted to enter your password after you run this command. Basically, all this does is open GRUB’s configuration file in gedit, the default text editor for Ubuntu. Since this is a system file, the “sudo” prefix enables us to make changes to the file as an administrator. We could have just navigated to /etc/default/grub in the file manager and opened the file, but we wouldn’t have been able to make changes.

#2: Tweak the default OS and timeout settings

By using the tweaks in this post, you can easily change the default OS in a dual-boot setup and maybe even shave a few seconds off your boot time.

By using the tweaks in this post, you can easily change the default OS in a dual-boot setup and maybe even shave a few seconds off your boot time.

We’re going to edit some values in this file, so be sure that you don’t accidentally delete something important. Locate the GRUB_DEFAULT setting. Delete the value that appears there (by default, 0) and replace it with the number you wrote down in step #1.

Optionally, you can also change GRUB’s default timeout length. Change the value of GRUB_TIMEOUT to whatever time (in seconds) you’d like. Three seconds is usually enough to change the selected OS. Since GRUB doesn’t appear instantly on my machine, I set it to five.

Once you’re done, save the document and close it.

#3: Update GRUB

Now that you’ve made changes to GRUB’s configuration file, you need to update GRUB to apply these changes. Open a terminal and type the following:

sudo update-grub

As before, you might be prompted to enter your password.

Finally, reboot your machine and verify your changes have been applied. If you aren’t satisfied with the tweaks you’ve made, you can easily repeat the above steps to make additional changes.

If you’re interested in learning more about GRUB, or if you’d like to trick out your boot menu with custom background images, I would highly recommend taking a look at Dedoimedo’s GRUB tutorials.

Advertisements

Posted on March 9, 2013, in Tips and Tweaks and tagged , , , , . Bookmark the permalink. 1 Comment.

  1. Thanks for that nice easy explanation. I will have to try it on another machine I have.

%d bloggers like this: