Dual-booting all versions of Windows and Linux

   Dual-Boot    |    Win 8    |    Win 7    |    Vista    |    Win XP/2K/NT    |    Win9x/Me    |    How to    |    Legacy 9x Tweaks    |    SiteMap   


Here: Home > How do I ... >

Edit GRUB & GRUB2 Boot Menu Options

Last reviewed: May 2010

On this page:
• Edit GRUB2 - Update May 2010
• What is GRUB?
• How to Backup the GRUB configuration file
• How to Edit the GRUB boot loader configuration file
• How to Restore GRUB
• How to Create a Bootable GRUB Floppy Disk
• Contents of Menu.lst

Edit GRUB2 - Update May 2010

The newer GRUB2 boot loader has been used in various distros of Linux since Ubuntu version 9.10. It is now used in most of the latest versions of Linux. GRUB2 has many changes most of which are not immediately obvious to the user.

Users no longer edit Grub.conf or Menu.lst in the /boot/grub folder. In fact, those files are now off-limits and you must NOT edit them. The file to edit is grub located in the /etc/default folder and it can be edited with this command from Terminal with Administrator privileges: (you must also run update-grub after any alteration).

sudo gedit /etc/default/grub
you may need your password

For example, change GRUB TIMEOUT=10 to GRUB TIMEOUT=1. Making it =0 is not advised.

Save and close the file after you have made your change(s). While still in the Terminal, run the following command to get the change(s) implemented on the next boot, and then exit the Terminal.

sudo update-grub
note the dash (minus sign) between update and grub

The rest of this page refers to the older version of GRUB but is still useful reading.

[top of page]

What is GRUB?

GRUB is an excellent and highly flexible boot loader. It's designed to boot a wide range of operating systems from a wide range of file systems. The Windows equivalent is NTLDR which can normally boot only the Windows operating systems. GRUB is now pretty much the standard used in the very many variations of Linux available today.

The GRUB file contains configuration options like default boot entry, timeout, password settings, color, and a list of boot menu entries. It's highly configurable by the user but caution is advisable. Even a minor but incorrect change can make the system unbootable. Checking for correct entries and typing errors is vital!

If you want to change GRUB's behaviour, you need to edit the Grub boot loader's menu configuration file. This is usually located at /boot/grub/menu.lst (that .lst file extension stands for list, not first). It's also sometimes at /boot/grub/grub.conf but can vary depending on the Linux distribution. Another common location is /etc/grub.conf but this is often a link to the /boot/grub file. This page will presume it is at /boot/grub/menu.lst.

Note: The information on this page relates to the Debian GNU/Linux used in Ubuntu. Debian is also used in Knoppix, MEPIS, Dreamlinux, Damn Small Linux, Xandros, Linspire, Sidux, Kanotix, LinEx, and others.

[top of page]

How to Backup the GRUB configuration file

Before you make any changes to the GRUB configuration file (Menu.lst), you are strongly recommended to backup the existing menu - just in case things do go wrong. You might even consider copying it to another machine, or printing the menu, or creating a GRUB floppy disk.

To make a simple backup of Menu.lst

Boot your Linux, and open a Terminal window (it's like a DOS window)
(Terminal is usually in Applications/Accessories).
At the prompt, type in, and press [Enter]
cp /boot/grub/menu.lst /boot/grub/menu.lst_bck
Menu.lst will be copied to Menu.lst_bck

[top of page]

How to Edit the GRUB boot loader configuration file

  1. Boot your Linux, and open a Terminal window
    (Terminal is usually in Applications/Accessories).
  2. Backup Menu.lst (see above).
  3. Type in, and press [Enter]
    sudo gedit /boot/grub/menu.lst
    you may need your password
    Menu.lst will open in your text editor.
  4. Make the required alterations to Menu.lst and check your changes twice!
  5. Save the Menu.lst file and reboot.

[top of page]

How to Restore GRUB from a Ubuntu Live CD

A Windows install, or some other occurrence, may erased/changed your MBR so that the GRUB boot loader menu no longer appears at startup or it returns an error. GRUB can be easily returned to its original location with the following commands.

  1. Run Linux from your Ubuntu Live CD, and open a Terminal window
    (Terminal is usually in Applications/Accessories).
  2. First get to a GRUB prompt. Type:
    sudo grub
  3. GRUB extends beyond the very small MBR.
    Find and note the location of GRUB's Stage 1. Type:
    find /boot/grub/stage1
    (if more than one Stage1 is located, you must choose which one to use).
  4. Replace the following hd?,? with the location just found. Type:
    root (hd?,?)
  5. hd0 is the GRUB label for the first drive's MBR (that 0 is a zero). Type:
    setup (hd0)
  6. Type:

Grub will be installed to the MBR and root (hd?,?). When you reboot, you will have the GRUB boot menu at startup.

It's not essential for GRUB to be written to the MBR on the first hard disk (hd0). If you want GRUB on a partition, the setup (hd0) step can be altered to setup (hdX,Y). The X part is the hard disk number (0=first disk, 1=second). The Y part is the partition number (0=first partition, 1=second, etc). This method will leave the MBR on (hd0) unchanged.

[top of page]

How to Create a Bootable GRUB Floppy Disk

This simple bootable floppy disk will boot GRUB from the floppy and bring you to a GRUB> prompt. Type help for a list of commands. Please visit one of the many excellent Linux support Web sites for further information on using native GRUB.

GRUB's Stage 1 and Stage 2 files must be copied to the first and second sectors of the floppy disk.

In the following, cd brings you to the location given. The dd command copies information sector by sector. if is the input file. of is the output file. /dev/fd0 is the first mounted floppy device. bs specifies the block size in bytes. Count is the number of blocks that will be copied, and seek tells how many blocks should be skipped before writing.

  1. Boot your Linux, and open a Terminal window
    (Terminal is usually in Applications/Accessories).
  2. Execute these commands:
    cd /usr/lib/grub/i386-pc
    dd if=stage1 of=/dev/fd0 bs=512 count=1
    dd if=stage2 of=/dev/fd0 bs=512 seek=1

[top of page]

Contents of Menu.lst

  • Hash: Any line beginning with # (hash) is only a remark to help the reader understand the following line(s). Hash lines are ignored. All lines without # are acted upon.
  • Default: The number after default represents the OS to boot by default. The first OS entry is number 0; the second is 1, etc. All entries are counted including a line of Other operating systems. If you wish, for example, to make the 5th entry the default boot, make it default 4.

    If you set the line to default saved, GRUB will always default to the last used entry (provided that entry contains the line savedefault) i.e. after running Windows your machine would boot to that Windows by default, and after running Ubuntu it will boot to Ubuntu by default.
  • Timeout: The Timeout option specifies how long in seconds the regular or hidden menu list will wait before automatically booting into the Default option.

    To make a Timeout of 10 seconds, change it to timeout=10
    To remove any Timeout, change it to: # timeout=
  • HiddenmenuIf the Hiddenmenu option is active, the boot menu is hidden during bootup and you must press a key to see it (probably ESC). To make it visible during bootup, place a hash (#) before it - #hiddenmenu
  • Typical Ubuntu Linux entry in Menu.lst:
    title Ubuntu 8.04.1, kernel 2.6.24-19-generic
    root (hd0,4)
    kernel /boot/vmlinuz-2.6.24-19-generic root=UUID=4d03a98a-aea0-4d94-95c9-330613bd5459 ro quiet splash
    initrd /boot/initrd.img-2.6.24-19-generic
  • Typical Windows XP entry in Menu.lst:
    # This entry automatically added by the Debian installer for a non-linux OS
    # on /dev/sda2
    title Microsoft Windows XP Professional
    root (hd0,1)
    chainloader +1
  • Remember GRUB starts counting at 0 (a 0 is the first; 1 is second, ...). That means, for example:
    /dev/hda1 in Linux equates to (hd0,0) in GRUB (hd0 = first hard disk and ,0 = first partition)
    /dev/hda2 in Linux equates to (hd0,1) in GRUB (hd0 = first hard disk and ,1 = second partition)
    /dev/hda3 in Linux equates to (hd0,2) in GRUB (hd0 = first hard disk and ,2 = third partition)
    /dev/hdb1 in Linux equates to (hd1,0) in GRUB (hd1 = second hard disk and ,0 = first partition)

[top of page]

Please remember that you alone are responsible for the consequences of any changes you make to your computer hardware or software.

Copyright © LarryM 1998-2015