GRUB Menu Selection and Editing


There has been a lot of confusion about how to edit your GRUB menus.  I will explain how to do this in this page.

Here is what a typical GRUB menu will look like when booting your PC.




 Ubuntu, kernel 2.6.20-16-generic                                     
 Ubuntu, kernel 2.6.20-16-generic (recovery mode)
 Ubuntu, memtest86+
 Other operating systems:
 Microsoft Windows XP Professional

  Use the  and  keys to select which entry is highlighted.
  Press enter to boot the selected OS, 'e' to edit the
  commands before booting, or 'c' for a command line.

  The highlighted entry will be booted automatically in 10 seconds.



This is an example of how I have a PC loaded.

There is typically a list of installed kernels with their corresponding recovery modes, a memtest86+, a separator, and another OS boot loader is you have another OS installed.

The controlling code for this menu is located in the
/boot/grub folder.  In the /boot/grub folder there is an editable text file called the menu.lst file.

The lines in the above example for a typical GRUB menu start at zero, always remember that.  That being said the default in the example is line 0.



If one would like to make the default Microsoft Windows XP Professional then you would set the default to 4.  To do that you will need to edit the text file as root.  To do so type the following in a terminal:

Make a backup of your
menu.lst file first.

sudo cp /boot/grub/menu.lst /boot/grub/menu.lst.backup

Then edit the text file as root.

gksudo gedit /boot/grub/menu.lst

This will bring up the gedit text editor.  Substitute gedit for your preferred text editor.  You will need to locate the following uncommentd line

default        0

It is normally the first uncommented about 15 lines down.  You would then change it to the following:

default        4

Save the file and the next time you boot the computer the Microsoft Windows XP professional line will be highlighted and you can simply press enter ot wait and XP will be loaded automatically.

DO NOT edit the text file and try to put the Microsoft Windows XP as the first line.  This will work, but the next time the Update Manager or you install a different kernel the top line will be erased in favor of the new kernel.  If this has happened use this to get GRUB to be able to add the proper menu entry back in.  Insert the text at the VERY END of the menu.lst file.  The following text assumes that XP is on the first partition of your primary hard disc.


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



If you look at the last line of the GRUB menu you will notice that there is a timer that is nothing is done then the default selection will be booted automatically.  The default is 10 seconds but that can be easily changed.  To change this parameter simply edit the
menu.lst text file and search for the following uncommented line:

timeout        10

If you want to change the time to say five seconds enter the following:

timeout        5

Save the file and the next time the PC boots up five seconds will be the timeout.  If you are truly impatient then set the timeout to zero and the menu will be bypassed all together.

All in all the GRUB menu is not difficult to tailor to your specific tastes.  There is a lot more that GRUB can do, so I recommend reading the comments in the
menu.lst text file before any editing takes place.

I hope this small tutorial has helped you.




Home