Fix Windows as default boot on Ubuntu with Grub2 loader

If you install Ubuntu on a machine that came with Windows pre-installed you have the choice of preserving Windows and chose each time you boot which operating system to run. By default, the boot menu will list the current Linux kernel, followed by any older Linux kernel versions, followed by a memory test and finally the original Windows version. By changing a GRUB boot loader configuration file you can chose which one is the default that gets booted when you just wait and don’t touch the keyboard.

(NOTE: The following instructions assume the Grub2 loader used in Ubuntu 9.10 – earlier versions are different)

For example, the menu might look like this:

Ubuntu, Linux 2.6.31-14-generic
Ubuntu, Linux 2.6.31-14-generic (recovery mode)
memory test (memtest86+)
memory test (memtest86+, serial console 115200)
Windows Vista (loader) (on /dev/sda1)

You can configure Linux to — unless you tell it otherwise — always boot Vista by setting GRUB_DEFAULT in /etc/default/grub to the number of lines above the entry you want to boot (4 in this case), instead of 0 (zero) for the top entry. After any change to /etc/default/grub you need to also run sudo update-grub:

joe@ubuntu910:~$ gksudo gedit /etc/default/grub


joe@ubuntu910:~$ sudo update-grub

The problem with that is, when the next kernel update comes out, two lines will be inserted at the top and your default value now selects the wrong entry:

Ubuntu, Linux 2.6.31-15-generic
Ubuntu, Linux 2.6.31-15-generic (recovery mode)
Ubuntu, Linux 2.6.31-14-generic
Ubuntu, Linux 2.6.31-14-generic (recovery mode)
memory test (memtest86+)
memory test (memtest86+, serial console 115200)
Windows Vista (loader) (on /dev/sda1)

You would need to manually select the latest kernel and repeat the above steps with a new value of 6 in this case. This is clearly a problem. Fortunately, there’s a simple workaround: use a name instead of a number for selecting the default. Here is how it works:

1) List the bootable operating systems:

joe@ubuntu910:~$ fgrep menuentry /boot/grub/grub.cfg
menuentry “Ubuntu, Linux 2.6.31-15-generic” {
menuentry “Ubuntu, Linux 2.6.31-15-generic (recovery mode)” {
menuentry “Ubuntu, Linux 2.6.31-14-generic” {
menuentry “Ubuntu, Linux 2.6.31-14-generic (recovery mode)” {
menuentry “Memory test (memtest86+)” {
menuentry “Memory test (memtest86+, serial console 115200)” {
menuentry “Windows Vista (loader) (on /dev/sda1)” {

2) Mark and copy the entry you want to stay bootable, including double quotes, for example "Windows Vista (loader) (on /dev/sda1)".

3) Edit the Grub configuration and paste the new value after the GRUB_DEFAULT= (in place of 0 or 4 or whatever number):

joe@ubuntu910:~$ gksudo gedit /etc/default/grub
GRUB_DEFAULT=”Windows Vista (loader) (on /dev/sda1)”
joe@ubuntu910:~$ sudo update-grub

Note: Make sure to close the gedit window before doing sudo update-grub

That’s it, no more Grub configuration tinkering required! 🙂

33 thoughts on “Fix Windows as default boot on Ubuntu with Grub2 loader

  1. Thanks for sharing the useful piece of information.
    However, trying to set OS name (“Windows Vista (loader)” in my case) to GRUB_DEFAULT didn’t work for me. I rechecked if I did everything right, but every time I rebooted Debian remained selected as the default OS. Setting the default time worked fine, though. Any idea?
    This is Grub 1.97~Beta3, if that’s a factor.

  2. Here it’s Grub 1.97~Beta4 — not sure if that would make much of a difference.

    You did run “sudo update-grub” after editing the file, didn’t you?

  3. Yeah, I did run update-grub.
    What I forgot to mention: the numerical value for GRUB_DEFAULT worked. But, as you said in your article, an upgrade to a newer kernel will need me to manually change the number again.
    I can only hope this glitch regarding setting OS_name will get fixed by then!

  4. Hi Tristan,

    can you email me ( this file from your machine:


    I am curious what’s different between your setup and mine!

  5. A much easier way to do this is to install Start up manager through synaptic…

  6. Thank you so much for taking the time to write this up. I came across it at the end of an Ubuntu 9.10 installation, at a meeting of my Linux group, on a PC that needed to dual boot into Windows by default. Your instructions worked perfectly for us.

  7. ThanX Joe!
    I got the link to your post from within #linuxmint-help chatbox.
    As an non-English non-Linux-expert I still had some struggle though!
    I would suggest to change your remark: ‘from double quote to double quote’ to ‘including double quotes’ and also add the advice to close the opened gedit-window before giving ‘sudo update-grub’ in terminal. I tried to do this command first, but then nothing happened, while I also seemed to have lost the auto-beginning of the next command, i.e. user@machine ~$ . After closing gedit, everything came allright do, according to sudden terminal-output-reaction!

  8. Thanks Joe,
    Worked for me.
    I installed Ubuntu on a Windows PC but for the time being still need the user to get used to Ubuntu
    so want to launch Windows by default. I will change that in the future:-)

  9. Thanks. Tried Startup Manager, but this changed the entry back to the numeric value of the default O/S. When I removed the memtest entries, Ubuntu became the default again.

  10. Hi there! I tried the original procedure, but my problem is, that since I updated ubuntu 9.10, Windows 7 is missing from the grub list, meaning, the boot loader and the grub. cfg file.
    I though maybe the new kernels were ‘pushing down windows 7, not allowing it to appear in the list, so I tried removing older kernels from synaptic as well, but they’re still listed. So I have no idea what to do to fix grub. I’m about to try 3 things; removing entries manually, running this code:

    $ sudo apt-get install –reinstall libdebian-installer4
    $ sudo os-prober
    $ sudo update-grub

    …or ultimately, reinstall windows to overwrite grub. I hope I won’t have to get to that though.

  11. Pingback: – Stuff I added on top of my default Ubuntu install

  12. Hi Joe 🙂
    That did not worked for me. But I have quick and dirty fix 🙂
    Neither setting default as number nor as long entry with quotes. But I did this:
    Open /boot/grub/grub.cfg
    Find windows entry near end of file. Entry is long e.g.:
    “Windows 7 (loader) on (/dev/sda2)” change that to “Windows7”
    make that default entry. That does it. I think it has something to do with that long names are not yet supported in grub2. (I read that somewhere, maybe it is bogus info) :)))

  13. Pingback: Grub 2 Fixes » Solo Technology

  14. Thanks Action Parsnip!

    THIS worked for me:

    sudo mv 30_os-prober 08_0s-prober
    sudo update-grub

    (StartUp Manager affects nothing FSDR)

  15. I though maybe the new kernels were ‘pushing down windows 7, not allowing it to appear in the list, so I tried removing older kernels from synaptic as well, but they’re still listed.

  16. hi..i have same loader doesnt move..because at the startup my Keyboard doesnt work…i went to hardware guy ..he changed startup from the BIOS setting and it worked like again same problem with to do it.. From BIOS ..i want to skip this whole..choose your OS step..plese help

  17. On typing
    sudo update-grub
    It displays –
    /etc/default/grub: Syntax error: “||” unexpected
    How to resolve this ?

  18. Hello Ankit, you should take a look at /etc/default/grub, e.g.

    sudo vi /etc/default/grub

    and look for syntax errors.

  19. Pingback: How do I set Windows to boot as the default in the boot loader?

Leave a Reply

Your email address will not be published. Required fields are marked *