boff

Editing /boot/grub/menu.lst to change the GRUB boot menu

January 17, 2007 · 38 Comments

I have an Ubuntu/WinXP dual-boot machine. The GRUB bootloader menu allows me to boot into several Ubuntu options or into WinXP. Unless I have to fix something (which I hope I won’t have to), I only ever choose the main Ubuntu option or WinXP. These options are, however, at either ends of the list. I’d prefer them to be next to each other for quick access.

Here’s a helpful reference. And here’s what I did:

The GRUB boot menu configuration is in the file
/boot/grub/menu.ls

1. backup menu.ls:
sudo cp /boot/grub/menu.lst /boot/grub/menu.lst-backup

2. edit menu.ls:
sudo gedit /boot/grub/menu.lst

3. Move the paragraph with the WinXP options up the list.

4. Change default to 1 (was 0)
default 1

5. comment out the lines about “Other operating systems

So now I have the following options when booting:

  • Microsoft Windows XP Professional
  • Ubuntu, kernel 2.6.17-10-generic
  • Ubuntu, kernel 2.6.17-10-generic (recovery mode)
  • Ubuntu, memtest86+

…and the second option is automatically selected and boots-up after 10 seconds if I don’t do anything.

Here is the contents of the resulting file (showing only the uncommented lines)

default 1

timeout 10

title Microsoft Windows XP Professional
root (hd0,1)
savedefault
makeactive
chainloader +1

title Ubuntu, kernel 2.6.17-10-generic
root (hd0,4)
kernel /boot/vmlinuz-2.6.17-10-generic root=/dev/sda5 ro quiet splash
initrd /boot/initrd.img-2.6.17-10-generic
quiet
savedefault
boot

title Ubuntu, kernel 2.6.17-10-generic (recovery mode)
root (hd0,4)
kernel /boot/vmlinuz-2.6.17-10-generic root=/dev/sda5 ro single
initrd /boot/initrd.img-2.6.17-10-generic
boot

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

I should emphasize the importance of the first step, i.e. backing up the original menu.ls file. I’d like to quote a comment on a relevant website here for future reference:

TuxGirl wrote: As a side note, I think it’s important to mention that, if you do manage to completely mess up your grub.conf [or menu.ls] file to the point that your machine won’t boot, you can fix it by booting into a livecd (like the Ubuntu livecd or Knoppix or DSL or *something*), and then copying your backup grub.conf [or menu.ls] over while in there. In fact, this method is great whenever you do something to your system that makes it temporarily unusable.

Categories: boot · installation · partition

38 responses so far ↓

  • FractalBrain // February 1, 2007 at 7:57 pm | Reply

    Hey there! Thanks for this post! I would like to make a note that others may find useful.

    Outcome: Grub remembers the last operating system/kernel it booted into and boots into that system next time, unless you select another operating system.

    How to do it: Goto the menu.lst you talked about and change the default field from zero to ’saved’. I believe they also have some commented instructions listed.

    Thanks again for you post, it helped.

  • boff // April 27, 2007 at 8:44 pm | Reply

    Thanks, I’ll have to try that.

  • Eric Klemm // April 29, 2007 at 5:20 pm | Reply

    I wanted to thank you for this post. I also have a dual-boot xp and ubuntu machine, I knew that I needed to backup menu.lst and grub.conf at least for reference when upgrading from edgy to feisty. I am glad to hear it went smooth for you. I have a SATA drive with ubuntu and a EIDE drive with xp. Anyone have any idea if this will make a difference with the upgrade? (I can’t lose xp right now, my wife uses it for school.)

  • Loving it! // May 5, 2007 at 6:55 am | Reply

    Thanks for the post.. I followed the instructions and it worked well so thanks… One question though, although my grub menu now appears as yours

    * Microsoft Windows XP Professional
    * Ubuntu, kernel 2.6.17-10-generic
    * Ubuntu, kernel 2.6.17-10-generic (rec mode)
    * Ubuntu, memtest86+

    My quesiton is that although windows is listed above, the option that is actually highlighted is the Ubuntu.. and still the default option.. Any ideas.. thanks

  • David Wykofka // May 7, 2007 at 1:43 pm | Reply

    If you followed the directions and ended up booting ubuntu as the default that is because the directions say to change the default to “1″ which is actually the 2nd entry on the boot list. If you want to boot the 1st entry change the boot option to “0″.

  • craynerd // August 29, 2007 at 11:32 pm | Reply

    Great tutorial and nice addition by David Wykofka, the default needs setting to “0″ if you want the default drive to be the top of the list in boot grub, i.e. windows xp in the above example.

    Thanks again guys!
    Chris

  • Bill // December 18, 2007 at 1:29 am | Reply

    Great tutorial – works great on my old Dell laptop dual booting XP/Ubuntu as a practice platform. I want to dual boot on my new HP machine running Vista/Ubuntu. Can I assume that the same set up can be used and GRUB will recognize the Vista OS for editing the default boot sequence?

  • Mark // January 4, 2008 at 1:23 pm | Reply

    My Ubuntu menu.lst contains a title to separate Windows boot and follows without a corresponding root statement. It is easy for me to rearrange or guess between 3/4/5, but my question is: “What is counted – title or root or what – when obeying the default value setting ?”

    Shame the entries aren’t numbered as part of the menu.lst generation (or actual mechanism) or name matched as that would be user friendly …we don’t want that in Unix-land do we ;-}

  • airtonix // January 19, 2008 at 9:42 pm | Reply

    yeah same problem, after kernel upgrade the no gets changed as the new kernel becomes the first option.

    and as someone pointed out savedefault only works for last optin used so if you always want windows booting by deaflt but have some people come to use ubuntu, then they have to reboot to windows before leaving.

    how to getaround this?

  • Wayne Walker // February 15, 2008 at 9:57 pm | Reply

    Question-Had dualboot winxp on drv c

  • Wayne Walker // February 15, 2008 at 10:00 pm | Reply

    Question-Had dual boot win xp on DrvC. Ubuntu 7.10 on USB drive. Upgraded to Vista now no more grub boot menu. How do I get dual boot? Windows boot does not see Ubuntu. Thanks

  • anggi // February 27, 2008 at 12:04 pm | Reply

    thanx man..!!

  • Gabriel Lord // March 18, 2008 at 6:11 am | Reply

    Hello all,
    I would like to thank you for the information you have provided. It was extremely handy when I needed to get my home system to dual-boot. I had another PC that the motherboard died on. So I took the hard drive out of it and added to my larger system that has Fadora 8 Ware Wolf. I have repaired the windows XP and it is now working on the new system. Now I am having a real problem getting the Grub to boot the Windows XP on the new hard drive. The only way I can boot the Windows XP hard drive is to switch to the boot menu on startup and select the Windows drive to boot from. When I try to boot windows from the grub boot menu it goes to a black text screen and says the path is unknown or unsupported. How can I get grub to boot the Windows hard drive? The way I have grub setup is listed below. Please let me know what I am doing wrong.
    :
    # grub.conf generated by anaconda
    #
    # Note that you do not have to rerun grub after making changes to this file
    # NOTICE: You have a /boot partition. This means that
    # all kernel and initrd paths are relative to /boot/, eg.
    # root (hd0,0)
    # kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
    # initrd /initrd-version.img
    #boot=/dev/sda
    default=1
    timeout=10
    title Microsoft Windows XP Professional
    root(hd1,0)
    savedefault
    makeactive
    chainloader +1
    title Fedora (2.6.23.1-42.fc8)
    root (hd0,0)
    kernel /vmlinuz-2.6.23.1-42.fc8 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
    initrd /initrd-2.6.23.1-42.fc8.img
    quiet
    savedefault
    boot
    :

  • gigato // March 21, 2008 at 6:05 pm | Reply

    I am having some problems with adding slackware to my grub I can seem to get the syntax right my setup is on my /dev/sda4 partition (extended) i have slackware installed on /dev/sda5 I’m using the code

    title slackware
    root (hd0,3)
    kernel /boot/vmlinuz rw root=dev/sda5

    grub will not let me boot into this partition on startup though

  • gigato // March 22, 2008 at 5:55 pm | Reply

    Ok so I changed some partitions around and reformatted some stuff. No my slackware is not on an extended partition and I’m getting error 2 in grub here is the syntax i’m using in menu.lst

    title Slackware (on /dev/sda3)
    root (hd0,2)
    kernel /boot/vmlinuz root=current ro vga = 769
    savedefault
    boot

  • wyliepops // May 5, 2008 at 1:42 am | Reply

    Simple instructions for this Ubuntu noob made it easy. Many Kudos!!!

  • Boot loader - Hardware Canucks // May 25, 2008 at 4:00 pm | Reply

    [...] look at the GRUB configurations sections. It should just be a matter of editing the menu.lst file. This may kick start you. Alternately, just reinstall Debian or a different distro and see if you maybe [...]

  • Alexis // June 23, 2008 at 2:56 pm | Reply

    En muchas ocasiones no funciona el gedit, y cuando esto sucede lo reeemplazamos por el comando nano, que nos permite editar el menu.lst, y despues de tene el menu.lst abierto podemos editar el gurb a nuestro gusto.

  • Ariszló // June 27, 2008 at 11:17 am | Reply

    Gigato wrote: “I am having some problems with adding slackware to my grub…”

    1. What is /dev/sda5 for Ubuntu is /dev/hda5 for Slackware.

    2. What is /dev/hda5 in the kernel line should be (hd0,4) in the root line.

    3. Replace rw with ro in the kernel line.

    So your Slackware section should look like this:

    title Slackware
    root (hd0,4)
    kernel /boot/vmlinuz root=dev/hda5 vga=769 ro

  • KIKE // July 3, 2008 at 4:55 am | Reply

    It’s not precise what fractal brain posted, because of this quotations made in the menu.lst :

    ## 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

  • ubuntu menu.lst - Computer Help & PC Help Forums - Provided By Free PC Help // September 11, 2008 at 5:53 pm | Reply

    [...] Wardy, The following link may help in regards to editing the menu.lst file Editing /boot/grub/menu.lst to change the GRUB boot menu boff Also, have a look at Ubuntu’s guide to dual booting with Windows XP. I followed this a while back [...]

  • Arun // October 11, 2008 at 4:06 pm | Reply

    Thanks. Exactly what I was looking for…

  • jummismHice // October 27, 2008 at 7:29 am | Reply

    I was exactly looking for something like that. Do you feel a vested interest in my open release Do you want a joke? :) How does a spoiled rich girl change a lightbulb? She says, “Daddy, I want a new apartment.”

  • Adam // November 2, 2008 at 5:44 am | Reply

    If I set the timeout to 0, does that mean that the default will load automatically each time, bypassing this screen?

  • boff // November 29, 2008 at 1:20 pm | Reply

    I am pleased that this post actually seems to be useful to some people out there…

    I am currently wondering if there is a way to have these changes to grub permanent. Right now, every kernel update changes things around again. Meaning I have to edit menu.lst each time. Any thoughts?

  • The Installation « The Linux Life // December 13, 2008 at 6:51 am | Reply

    [...] may be a little difficult for the average computer user. However, Googling does bring up some nice results on how to edit the boot menu. Filed under: The Beginning [...]

  • 8800 GT drivers for Windows 7. - Page 2 - Overclock.net - Overclocking.net // January 15, 2009 at 4:47 am | Reply

    [...] I’d still uninstall Ubuntu, because I don’t think I installed it properly). Check out this to change what boots up by default with grub. Basically you just need to edit /boot/grub/menu.lst [...]

  • Rasto // January 29, 2009 at 10:23 am | Reply

    Yes, Boff, I would be also interested if there’s a way how to keep the grub settings even after reinstallation. Because, as you say, then you have to edit it again…

  • Rasto // January 29, 2009 at 1:26 pm | Reply

    One more useful thing: Have you ever thought about having a background picture in the Grub boot menu? I’ve just inserted one by downloading the following package: ’sudo apt-get install grub-splashimage’ (a set of pictures to be found in /boot/grub/splashimages/) and gediting my menu.lst – insert this line into your menu.lst: ’splashimage=(hd0,X)/boot/grub/splashimages/Y.xpm.gz’, where ‘X’ is the number of the Grub partition and ‘Y’ the picture name (e.g. ‘bike_gua.xpm.gz’). Also works with your own pictures, you just have to convert them.

  • riverbuoy // February 25, 2009 at 7:45 pm | Reply

    For Gabriel Lord (a bit late) but might be useful for others.
    All Windows versions will only boot if it thinks it is on the first drive in the system.
    So you need to use the ‘map’ command to make it think it is on the first drive, and change root to rootnoverify.
    So change
    root(hd1,0)
    to the following two lines
    map (hd1) (hd0)
    rootnoverify (hd0,0)

  • Via Epia PX and VX700 and Video - tkArena Forums // April 1, 2009 at 8:40 pm | Reply

    [...] then boot to this new kernel. I modified /boot/grub/menu.lst to make it default. Editing /boot/grub/menu.lst to change the GRUB boot menu boff Next install via’s drivers if you haven’t already.. The default /etc/X11/xorg.conf worked for me [...]

  • Richard // April 28, 2009 at 1:03 pm | Reply

    Is it possible to have Ubuntu boot up after 10 seconds but Windows highlighted so that just pressing enter boots it?

    I know it’s only one less keystroke but it means less thinking about it:

    . o O (What order are they in? Do I press up or down?)

    Thanks.

  • Micah // May 15, 2009 at 5:32 pm | Reply

    So, it looks like a few people mentioned this earlier, but:

    The line
    Default x
    works like this:
    0= 1st OS in the order of your list
    1= 2nd OS
    3 = 3rd OS

    So, if you have moved windows to the first spot, you will need it to be

    Default 0

    Thanks

  • harshal // July 9, 2009 at 7:26 am | Reply

    I have a great problem basically yesterday i installed windows and then my grub is gone then i followed the normal procedure to get reinstalled the grub via live cd

    but the problem is when at the end i type setup (hd0,6)
    and press enter it shows everything fine it seems that my grub is reinstalled but when i reboot it boot by default to windows XP what should i do now

  • rookslide // July 25, 2009 at 3:43 pm | Reply

    I’m the newest noob to learn Linux.
    Thanks to all for this thread!

    Just fixed the boot options so the family isn’t hating me too! Plus I rid myself of a couple of other versions I don’t have installed but keep showing up on the boot list. Trying to break free from XP but change is a lil bit scary. Hard to just up and drop a tried and true, even if you do hate the evil empire parenting it.

    Thanks again all!

  • steve // September 19, 2009 at 11:58 am | Reply

    Good article..the following post will shed more light though..
    http://pitstop87.blogspot.com/2009/08/changing-boot-parameters.html

  • Harshad Joshi // October 1, 2009 at 10:26 am | Reply

    where can i find the kernel title?

    i manually compiled a kernel in debian and expected that its title should not be debian, but on installing the deb package, it gets entered as

    title debian kernel 2.6.N in /boot/grub/menu.lst

    How to change this thing automatically?

    and why on hell is it using debians name when the kernel isent debian??

    grub sucks or what?

  • Anticom // October 12, 2009 at 1:19 pm | Reply

    Exactly what I was looking for =)

Leave a Comment