How do I set the bootloader so that in my dualboot with Windows 7/Ubuntu 11.04, Windows start up as standard instead of Ubuntu?
How do I set the bootloader so that in my dualboot with Windows 7/Ubuntu 11.04, Windows start up as standard instead of Ubuntu?
/etc/default/grub
fileThere are two ways of doing this using editing a grub file. These are described in the Ubuntu Community Documentation Grub2 page
The two ways are:
To start we need to find out what we are booting or want to boot. Open a terminal with Ctrl+Alt+t and type in
sudo grep menuentry /boot/grub/grub.cfg
user@YourComputer:~$ grep menuentry /boot/grub/grub.cfg
[sudo] password for user:
menuentry 'Ubuntu, with Linux 2.6.35-31-generic' --class ubuntu --class gnu-linux --class gnu --class os {
menuentry 'Ubuntu, with Linux 2.6.35-31-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
menuentry 'Ubuntu, with Linux 2.6.35-30-generic' --class ubuntu --class gnu-linux --class gnu --class os {
menuentry 'Ubuntu, with Linux 2.6.35-30-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
menuentry "Memory test (memtest86+)" {
menuentry "Memory test (memtest86+, serial console 115200)" {
menuentry "Windows NT/2000/XP (loader) (on /dev/sda1)" {
menuentry "Ubuntu, with Linux 2.6.32-34-generic (on /dev/sdb1)" {
menuentry "Ubuntu, with Linux 2.6.32-34-generic (recovery mode) (on /dev/sdb1)" {
menuentry "Ubuntu, with Linux 2.6.32-33-generic (on /dev/sdb1)" {
menuentry "Ubuntu, with Linux 2.6.32-33-generic (recovery mode) (on /dev/sdb1)" {
menuentry "Windows Vista (loader) (on /dev/sdc1)" {
You can see that the "saved" method can come in handy when booting multiple operating systems. Save the name of the entry you want e.g. Windows NT/2000/XP (loader) (on /dev/sda1)
, we need it later.
/etc/default/grub
fileType in the terminal
sudo nano -B /etc/default/grub
and your password if asked. The nano editor will open.
A. Saved method - In my preferred way, I made the following changes from the standard grub file.
I changed the value of GRUB_DEFAULT
to saved
:
GRUB_DEFAULT=saved
I enabled the SAVEDEFAULT functionality by adding the following line:
GRUB_SAVEDEFAULT=true
B. Specific menuentry - In the way you are asking for
Change the value of GRUB_DEFAULT
to the name of the Windows system you want to always boot. The name of the corresponding Grub menuentry can be found as described in the previous section.
I wanted to have Window XP always set as default at boot, I would set GRUB_DEFAULT
to "Windows NT/2000/XP (loader) (on /dev/sda1)"
:
GRUB_DEFAULT="Windows NT/2000/XP (loader) (on /dev/sda1)"
Note: Some versions of Ubuntu require single quote (') vice double quote (").
You could also set GRUB_DEFAULT
to the line number in the menu entry list (with 0 being the first), but when the kernel in Ubuntu is updated grub adds the new kernel to the top of the list, you would have to change the number, since Windows is the last one in the menu entry list. You can see this in my menu entry list.
Now you have to run
sudo update-grub
to update the system generated grub.cfg
file in the /boot/grub/
directory.
user@YourComputer:~$ sudo update-grub
Generating grub.cfg ...
Found background: /usr/share/images/grub/Apollo_17_The_Last_Moon_Shot_Edit1.tga
Found linux image: /boot/vmlinuz-2.6.35-31-generic
Found initrd image: /boot/initrd.img-2.6.35-31-generic
Found linux image: /boot/vmlinuz-2.6.35-30-generic
Found initrd image: /boot/initrd.img-2.6.35-30-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows NT/2000/XP (loader) on /dev/sda1
Found Ubuntu 10.04.3 LTS (10.04) on /dev/sdb1
Found Windows Vista (loader) on /dev/sdc1
done
nano
is especally easy to use in the terminal. Move around with the arrow keys. Type in you addtions, delete the unwanted.
The -B
or --backup
option backs up the previous version of it to the current filename suffixed with a ~
. Very handy in case of the dreaded Fat pfinger effect.
When you are through, Ctrl+o will allow you to save your edits by hitting Enter and Ctrl+x will close. These and other options are shown at the bottom of the terminal screen with the ^
indicating Ctrl.
^G Get Help ^O WriteOut ^R Read File ^Y Prev Page ^K Cut Text ^C Cur Pos
^X Exit ^J Justify ^W Where Is ^V Next Page ^U UnCut Text ^T To Spell
Some in the Ubuntu community suggest sudoedit
instead of nano
. I recommend nano
— which is the default sudoedit editor in later distributions of Ubuntu — instead of sudoedit
, because the default can be overridden in non-obvious ways, unless you are an administrator. sudoedit
is safer in that it automatically saves a backup copy of the edited file, but the -B
command line option in nano
does the same thing. nano
is more intuitive than editors like vi
or emacs
, which are very flexible but require learning a lot of commands, shortcuts or different modes.
If you prefer not to use the nano
editor and prefer the Gnome Text Editor, instead of sudo nano -B
use gksu gedit
. I generally do this for large files, and /etc/default/grub
could easily be considered a large file. Thus type in gksu gedit /etc/default/grub
instead of sudo nano -B /etc/default/grub
. Note that the Gnome text editor does not automatically make a backup!
I made some changes to grub for my personal needs. Such as the background picture of the moon launch. How to do these are discussed at the Ubuntu Community Documentation page on Grub2, recommended.
Good luck!