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

UPDATE (April 2010): The information in this post is outdated! Most linux distributions, including Ubuntu, are moving to GRUB 2. Because the contents of this post is about the previous version of GRUB, it is fast becoming obsolete. More about GRUB 2 here: https://help.ubuntu.com/community/Grub2

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

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

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

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

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.


53 responses to “Editing /boot/grub/menu.lst to change the GRUB boot menu

  1. 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.

  2. Thanks, I’ll have to try that.

  3. 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.)

  4. 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

  5. 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”.

  6. 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!

  7. 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?

  8. 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 ;-}

  9. 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?

  10. Question-Had dualboot winxp on drv c

  11. 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

  12. 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
    title Microsoft Windows XP Professional
    chainloader +1
    title Fedora (
    root (hd0,0)
    kernel /vmlinuz- ro root=/dev/VolGroup00/LogVol00 rhgb quiet
    initrd /initrd-

  13. 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

  14. 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

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

  16. Pingback: Boot loader - Hardware Canucks

  17. 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.

  18. 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

  19. 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

  20. Pingback: ubuntu menu.lst - Computer Help & PC Help Forums - Provided By Free PC Help

  21. Thanks. Exactly what I was looking for…

  22. 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.”

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

  24. 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?

  25. Pingback: The Installation « The Linux Life

  26. Pingback: 8800 GT drivers for Windows 7. - Page 2 - Overclock.net - Overclocking.net

  27. 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…

  28. 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.

  29. 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
    to the following two lines
    map (hd1) (hd0)
    rootnoverify (hd0,0)

  30. Pingback: Via Epia PX and VX700 and Video - tkArena Forums

  31. 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?)


  32. 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


  33. 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

  34. 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!

  35. 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?

  36. Exactly what I was looking for =)

  37. When I type “sudo gedit /boot/grub/menu.lst” nothing shows up thus I can’t edit anything. What is wrong here?

  38. Hi i have a big problem with the menu.lst i have changed and now when it starts it shows me just one kernel and that one is for the Memtest86 now i can not enter to linux to change the menu.lst
    the changes that i have made were just i putted an # before the titles of the kernel how can i fix this ? is urgent ,need u help ?

  39. It’s always a good idea to leave at least one old “known working” kernel on the list. Just in case something happens. You never know.

  40. i want to know what do you write in the root part where you write root (hd0,0)…i know what hd0 is…i dont know what the preceding 0 or whatever number is written into it is…
    also what does ro and the word following it generally mean ?

  41. sorry…i meant following zero and not preceding zero in my above post..

  42. Thanks for this post. This is what I for looking for. Will have to try in anyways.

  43. sudo gedit /boot/grub/grub.cfg

    That solved my issue. I wish startupmanager allowed editing the name of a menuentry as well as deleting a double entry.

  44. i have grub version 1.97~beta4 and there is no menu.lst file in the grub directory
    can anyone help me?

  45. Need Help – Urgent!!

    I have a DELL Inspiron mini 910, with OS Ubuntu 8.08

    I didn’t make back-up of menu.lst and now my OS doesn’t start. It has a bucle mode, where always enters to a system diagnostic.

    Before entering to this menu of diagnostic, it appears:


    Loading DMRK Version 8.00…

    HIMEM.SYS 8.09

    DRMK Version 8.00 (Build 00007)
    Copyright (c) 2005 Dell Inc. All rights”

    How can I recover the configuration?

  46. Pingback: Grub how to install

  47. Pingback: GRUB Error 15: Dual Boot Slack and OpenIndiana

  48. is there any gui tool for editing grub? the old method editing /boot/grub/menu.lst is deprecated in new versions

  49. In the newer versions, the menu.lst is replaced by the grub.cfg. The grub.cfg file shouldn’t be manually modified. We need to run $update-grub.
    This command will read the kernel images in the /boot directory and creates grub.cfg file. Its is better to take a back up of grub.cfg before running the update-grub. Remember that you need be in root to do these.

  50. Thanks for the post. This helped me restore a lost option to boot up Windows.

  51. Pingback: Grub Hard Disk Error Gentoo

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s