Changing GRUB boot order to boot Windows XP before Ubuntu

April 29, 2007

One goal of installing Ubuntu is to help ease my wife and kids onto it – not to create a huge problem with the family. After the Ubuntu install the default boot ed OS was Ubuntu – not Windows. That’s going to be a problem.

So I went on a mission to figure out how to change the boot order to load XP by default.

I knew that Ubuntu was using the GRUB boot loader. I wasn’t familiar with GRUB so I don’t know why I knew this – it must have been stated during the install sometime. But anyway – I knew it was GRUB.

I Googled for “change GRUB boot order” and the first hit was exactly what I needed. I needed to edit /boot/grub/menu.lst.

I copied the file into my home dir and used chmod (it’s been so long since I’ve used a *nix CLI that I had to lookup chmod – I knew it was “ch” something) so I could write to it then opened it in xemacs.

I simply copied the XP settings ahead of the Ubuntu settings in the item list and left everything else the same.

The relevant parts of the original menu.lst were:

—————————- /boot/grub/menu.lst —————————————-

default 0
timeout 10

## ## End Default Options ##

title Ubuntu, kernel 2.6.20-15-generic
root (hd0,1)
kernel /boot/vmlinuz-2.6.20-15-generic root=UUID=12de9aee-c011-429e-b2a9-0ed83b3eb727 ro quiet splash
initrd /boot/initrd.img-2.6.20-15-generic

title Ubuntu, kernel 2.6.20-15-generic (recovery mode)
root (hd0,1)
kernel /boot/vmlinuz-2.6.20-15-generic root=UUID=12de9aee-c011-429e-b2a9-0ed83b3eb727 ro single
initrd /boot/initrd.img-2.6.20-15-generic

title Ubuntu, memtest86+
root (hd0,1)
kernel /boot/memtest86+.bin


# This is a divider, added to separate the menu items below from the Debian ones.

title Other operating systems:

# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1

title Microsoft Windows XP Home Edition
root (hd0,0)


I referred to the online GRUB manual ( and confirmed that the “0” in default was the list item to boot by default (zero-indexed) and that if it were changed to “saved” the previously loaded item with a “savedefault” entry would be used. I didn’t want that. I want it to boot to XP by default regardless of what I used most recently.

I had two choices – change the default value to 4 (the menu divider is an option as well) or leave it at 0 and reorder the items.

I decided to reorder the items for one reason – I want the top menu item to be the default because that is how my family will expect it to work.

There are some notes about an automatically generated section that could be over-written so I did back up the file before making the change and I decided it was worth the hassle of losing the customizations I made (and possibly the Window’s item) to make it work the way we need for now. I don’t plan to change it often.

So I simply moved the XP section to the top, moved the divider below it, saved the local copy and copied it over the original.

Rebooting brought up XP after a 10 second delay – just as I had hoped.

Note – I reverted the changes and used a simplier approach that kernel updates won’t overwrite.

About these ads

21 Responses to “Changing GRUB boot order to boot Windows XP before Ubuntu”

  1. gus Says:

    pleace in espanish (espaÑo), solicito una copia pe este texto en español, para poder tener un mayor entendimeieno te su contenido. gracias por si atencion

  2. makingtheswitch Says:

    Re: gus,

    I think you are asking for a translation into Spanish. I can only suggest babelfish – a link to the translation is:

  3. Rob H. Says:

    As a long-time Linux user, it’s pretty neat to see the learning process of someone just starting in first-hand. I hope you enjoy the switch, and look forward to your future articles.

  4. Philip Says:

    chmod isn’t usually necessary to edit read-only files. Just use sudo (e.g. sudo xemacs /boot/grub/menu.lst).

  5. Ohad Lutzky Says:

    First off – I hope you are enjoying the speed Ubuntu runs at currently. The LiveCD is, as you suspected, very slow, and things should be going much faster for you know.

    As for this specific issue of Grub – I absolutely DESPISE having to have new users mess with text files and the CLI, to do something as widely-requested as changing the default booted OS. This is why I created a small program for the purpose, and I’m hoping it will become part of Ubuntu:

    (By the way, the Launchpad community is worth taking a look at)

  6. bigo Says:

    Good Lord, it has to be hard climbing out of the windows dumb experience. Sorry I don’t want to offend it’s just that you look so cute trying to figure out things by yourself!! Keep trying your best and welcome to the *nix world!!

  7. Brian Says:


    Basicamente dice que queria, para no complicar la transicion para su mujer y sus hijos, que Windows se abriera automaticamente al prender la computadora. El programa que maneja la orden segun la que se lanzan diferentes sistemas instalados en el disco duro es GRUB. Los parametros de GRUB se especifican en un archivo que se encuentra en /boot/grub/menu.lst . Lo que el indica aqui es que el comportamiento ‘default’ (es decir, automatico, lo que hace un programa sin intervencion del usuario) era primero lanzar Ubuntu, con el ‘kernel’ (nucleo? no se como se diga eso en espan~ol) que aparece en la primera parte de la lista. El simplemente puso la parte final, donde viene la informacion sobre la instalacion de windows, a la cabeza de la lista. No se si esto sea suficientemente claro, si hay alguna parte en particular que quisieras que tradujera deja otro comentario en este foro.


    I think this guy would benefit from seeing the final version of the /boot/grub/menu.lst, if there is a convenient way of posting that, I think he may just be missing the part about: “So I simply moved the XP section to the top, moved the divider below it, saved the local copy and copied it over the original.” Thanks, I flowed in via Digg, neat site.

  8. alt+f2, gksudo /boot/grub/menu.lst

    This is a lot faster than copying it to your home (~/), working on it, and copying it back.

  9. Keith Kimber Says:

    Thanks for this narrative.
    It’s eight years since I discovered Linux and Open Source. Eight years of trial and error to understand the basics of the strange language of operating systems and programming. Frustratingly time consuming but also fascinating, compelling … I want to be part of this, even if only as a thinking consumer of its creative output. The cost is huge in terms of lost sleep, disastrous mistakes, strained marriage …
    OK I know the Knowledge is really all there in the forums, but as an amateur, it’s hard to take in all that detail, if not the techie jargon and make it happen. It leaves me feeling stupid.
    This last two years it’s all got so much easier with the rise of Ubuntu. Your well told story reflects my story of getting to know the last three versions. Fewer than ever hardware glitches, or command line interventions. Hooray!
    However, even my new Linux-drivers-supplied all in one printer and scanner kit (bought to replace one which didn’t work out of the box), doesn’t work out of the box as promised. What is it with scanners and Linux? (Don’t tell me I don’t care I just want it to work.)
    I’ve been dual booting, not live CD flirting, for the last four years and would have made the Big Switch ages ago, so high a regard I have for the Linux project. However, it’s the real world-of-work interface that hits me in the cold light of Monday. Microsoft based programs still have too much of my vital data, that would take too much time and effort to liberate, or make platform independent.
    I dream I’ll wake up and be able to scan and print, access data, get my vital fix of BBC News outputs, audio and video, first time out of the box. Nearly there, but not quite. It’ll come in time. Next year, maybe.
    Meanwhile, it’s a fight to resist the temptation to spend good money on a Mac and get all the functionality with minimum hassle first go, and have the by now familiar *nix structure to populate with my meagre daily creative output.
    I’m following your story all the way.

  10. Clay Says:

    It’s interesting to read your posts because I went through a similar process about 9 months ago. With my girlfriend away for 2 months and a string of hardware bad luck (including the inability to find a non-Toshibafied version of XP Tablet Edition), I said screw it and installed Ubuntu. I quickly became an addict.

    I loved learning and tweaking. Downloading opensource alternatives to programs that I paid a lot of money for on the PC. It was so close to being exactly what I needed.

    In the end, my productivity dropped because I spent too much time configuring (for fun), installing, tweaking, etc… I needed a new laptop, so I bought my first Mac in 12 years. I love it. However, I keep Ubuntu on a second laptop that I’m using for pet projects. In fact, it was just 2 days ago that I bought a book about Ruby programming and installed Rails on the Mac and Ubuntu machines.

    Guess what? Installing and configuring on Ubuntu was 3 times faster and easier (at least) than doing the same on OS X. Now, as soon as I can get my hands on a Mac version of CS3, I’m axing the XP partition and setting up an Ubuntu virtual machine with Parallels. I’m just addicted to the tweaking — even to the point that my girlfriend had to ask me why I was always creating problems for myself on my computer. ;)

    For fun, of course!

  11. charmy Says:

    I did the same thing before and ran into a couple problems. It seems that if you update ubuntu to a new kernel it will overwrite the top or move everything down in order to add the boot option for that new kernel. Well for me when it did this it would overwrite my windows XP menu item leaving only the multiple versions of ubuntu as my options. So I just changed the default value to XP’s value. You will probably have to change it when the list grows but at least XP will still be an item. You probably have the newest kernel anyways so you won’t notice until an update but just wanted to let you know of possible problems.

  12. Brandon Ess Says:

    What job do you have at Microsoft? Why is Windows so slow to evolve. Is this Bill Gates choice? I mean he has all that money, why not have an OS that isn’t so buggy.

    Anyways I’m glad you made the switch to Ubuntu you can relax and breath now. No more Virus, Spy ware, and you can get all the software you need for FREE.

    Did you like what Apple said about their reason for delaying Leopard….cause Vista SUCKS!!! LOL

    We welcome you back to the open source community.

  13. jackson Says:

    “I Googled for “change GRUB boot order””

    Shouldn’t that be “I live’d for “change GRUB boot order””? ;)

  14. Janne Says:

    If you put your Windows entry above the “### BEGIN AUTOMAGIC KERNELS LIST” line it will remain there and will not be deleted of modified by newer kernel upgrades.
    You can remove the divider entry or keep it, it’s just cosmetics.

  15. Mackenzie Says:

    The “automagic” Debian thing is for every kernel update it redoes that section to match whatever’s inside /boot/, so if you uninstall some older kernels (I run unstable, so by Feisty stable I had about 10 kernels), that will automatically change to match just what you have installed.

    Also, that shouldn’t be
    gksudo /boot/grub/menu.list

    you need
    gksudo gedit /boot/grub/menu.list
    (since gedit is the text editor)

    gksudo/gksu are for running grahical applications. sudo is for terminal ones. alt+f2 is a little runbox for graphical ones or terminal things that don’t require any further input.

  16. [...] file and save it to your home folder or desktop. You can simply move XP to the top of the list, following these directions but keep in mind, as the author notes, these will be overwritten when Ubuntu updates. In the same [...]

  17. Paul Says:

    @ Mackenzie: you mean /boot/grub/menu.lst NOT menu.list! This command line stuff is hard enough–don’t complicate it by introducing typos. Take a second to check what you wrote and save all of us beginners a bit of pain . . .

  18. Ken Says:

    first open terminal:
    sudo gedit /boot/grub/menu.lst
    second password:
    third scroll down list within the default section with the ## “Pound signs”
    Find default 0
    change the 0 or 1 or 2 or 3 or 4
    How to figure what number you need?
    Start to count with Zero then when you get the OS you want to boot with in the Grub Menu Automatic boot menu… I used 4. for my XP Pro. You start at Zero and count each entre, to include the divider..

    Last Click Save This works for Ubuntu!

  19. Mark Reynolds Says:

    It would have been easier to use SUM (Start up manager)
    Go to the website
    You will find a lot of use full software for Ubuntu

  20. Brad Says:

    I put Windows above the ## Begins automagic kernel stuff so that it will not be overwritten. Also wrote myself a note incase I forgot what I did, so don’t be afraid to write your own notes, putting a # first on the lines that you do that.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: