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

Restore or reinstall the GRUB Boot Loader Menu

Last reviewed: September 2008

On this page:
• What is GRUB?
• How to restore GRUB

May 2010:
You should go to this page
for instructions on the newer GRUB2 and on repairing any Windows boot sector and Boot Loader.

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 or BCD which can normally boot only the Windows operating systems. GRUB2 is now pretty much the standard used in the very many variations of Linux available today.

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, and LinEx, among others.

[top of page]

How to restore or reinstall GRUB from a Ubuntu Live CD

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

It will be assumed that GRUB was installed into the MBR (hd0) of the first hard disk.

  1. Run Linux from your Ubuntu Live CD, and open a Terminal window (it's like a DOS 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 and has different Stages.
    Find and note the location of GRUB's Stage 1. Type:
    find /boot/grub/stage1
    You will be shown the location of Stage1, like (hd0,4)
    (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:
  7. Open Partition Editor and right-click the partition where GRUB is setup - usually (hd0).
    Select Manage Flags and make sure the Boot flag is ticked for this partition.
  8. Exit GParted, and Restart. Remove the CD when it pops out.

When you reboot, you will have the GRUB boot loader 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 Primary 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 Primary partition number (0=first partition, 1=second, etc). This method will leave the MBR on (hd0) unchanged.

Remember that 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