BlogGalleryAbout meContact

How to restore GRUB bootloader

Problem: GRUB may be used as a bootloader for a Linux installation. It can also be used for booting multiple operating systems (e.g. Ubuntu Linux, Windows XP, Windows Vista, even Mac OS X if you were able to install it on your PC!). It is normally installed on MBR. If GRUB somehow got corrupted, you will not be able to boot your Linux installation or any other operating systems that were loaded by GRUB. You may also need to restore your GRUB after reinstalled your Windows OSes.

Solutions: under such circumstances, you may restore the default MBR to boot individual Windows installations (see my previous post), or reinstall GRUB. Use the following steps to restore your GRUB:
1. Boot with any Linux live CD/DVD (e.g. Knoppix or Ubuntu Live CD/DVD)
2. Get a root shell (e.g. Applications / System Tools / Root Terminal)
3. Make a folder (e.g. mkdir /mnt/linux)
4. Identify the Linux root partition (i.e. fdisk -l) (e.g. my Ubuntu root partition is /dev/sda2)
5. Mount the Linux root partition (i.e. mount -t ext3 /dev/sda2 /mnt/linux) (replace /dev/sda2 with your Linux root partition determined at step 4)
6. Mount proc (i.e. mount -t proc none /mnt/linux/proc)
7. Mount udev (i.e. mount -o bind /dev /mnt/linux/dev)
8. Chroot to the mounted partition (i.e. chroot /mnt/linux)
9. Restore Grub (i.e. grub-install /dev/sda)
10. Exit the shell
11. Reboot
An alternative approach to STEP 9 (if grub-install does not work for you):
1. Get a root shell
2. run grub (i.e. type "grub" at the shell)
3. find /boot/grub/stage1 (it would return some thing like (hd0,2))
4. root (hd0,2)
5. setup (hd0) (this would install grub on MBR, alternatively setup (hd0,2))
6. quit
NOTE: You may need to remove the cached device map (i.e. /boot/grub/device.map) before attempting to restore GRUB.
 Permalink