|
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
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.
- Run Linux from your Ubuntu Live CD, and open a Terminal window (it's like a DOS window)
(Terminal is usually in Applications/Accessories).
- First get to a GRUB prompt. Type:
sudo grub
- 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).
- Replace the following hd?,? with the location just found. Type:
root (hd?,?)
- hd0 is the GRUB label for the first drive's MBR (that 0 is a zero). Type:
setup (hd0)
- Type:
quit
exit
- 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.
- Exit GParted, and Restart. Remove the CD when it pops out.
When you reboot, you will have the GRUB boot loader menu at startup.
Note:
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]
How do I ... Center
[top of page]
* ALWAYS BACKUP FIRST * ALWAYS RECORD SETTINGS * ALWAYS MAKE ONE CHANGE AT A TIME
Copyright © LarryM 1998-2012
thpc@mail.com
|