Set Windows as the Permanent Default OS when Dual-Booting with Ubuntu

January 9, 2009 - Reading time: 4 minutes

Ubuntu Linux is a great operating system, but one potential annoyance is how it automatically sets itself as the default OS when installed as a dual-boot with Windows. Fortunately, it’s easy to switch it back by editing GRUB (GRand Unified Boot Loader).

To modify GRUB, first boot into Ubuntu, then launch a Terminal (Applications -> Accessories -> Terminal). Type the following command:

sudo gedit /boot/grub/menu.lst

(Tip: if you don’t want to launch a full text editor, just substitute nano instead of gedit.)

Scan the file until you find this section:

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify ‘saved’ instead of a number. In this case, the default entry
# is the entry saved with the command ‘savedefault’.
# WARNING: If you are using dmraid do not use ‘savedefault’ or your
# array will desync and will not let you boot your system.
default 0

The number that follows the word default at the bottom is the critical part. Conventional wisdom suggests that we just have to change the zero to a higher number (usually between 4 and 6). Sure, you can do it that way if you want. Just find the section in your GRUB file at begins with: ### END DEBIAN AUTOMAGIC KERNEL LIST.

Starting with 0, count the entry blocks below that marker to find what the appropriate number is for Windows.

Be warned: the above method is only temporary. The next time a new kernel is passed down through the Update system, GRUB will likely add a new entry for it, breaking your default OS. You may find your computer furiously trying to boot the GRUB divider!

The Permanent Method

To fix that annoying little problem permanently, just type saved instead of a number, so that your GRUB file looks like this (emphasis is mine):

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify ‘saved’ instead of a number. In this case, the default entry
# is the entry saved with the command ‘savedefault’.
# WARNING: If you are using dmraid do not use ‘savedefault’ or your
# array will desync and will not let you boot your system.
default saved

The saved option works because Ubuntu so kindly already specifies Windows as the default when this option is invoked. Don’t believe me? Take a look at the very bottom of your GRUB file (emphasis is mine):

# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1
title Microsoft Windows XP Professional
root (hd0,0)
savedefault
chainloader +1

Save your GRUB file and reboot. Don’t be alarmed if your computer does not immediately default to Windows. I found that I had to manually switch it to Windows once, but then GRUB remembered my choice after that.

About

Tech tips, reviews, tutorials, occasional rants.

Seldom updated.