Wednesday, May 26, 2010

Repair your GRUB loader

GRUB is the bootloader of choice for Ubuntu, it is flexible and can be edited to load windows partitions if needed. Every once in a while windows may have the inclination to overwrite your bootloader with its own. This will make accessing your Ubuntu box a mission - fear not, I have a quick solution ;) Follow these steps to repair your GRUB loader:

Boot your PC with an Ubuntu Live CD in the drive

Open a shell (Terminal)

Type the following to re-configure GRUB

sudo grub

Type the following followed by the TAB key

root (hd

This will provide you with a list of possible physical drives eg:

hd0 or hd1

Type the number of the drive you installed ubuntu on, not to worry if you unsure, the next step with tell you if you on the right path. Add a ‘,‘ after the number and press the TAB key again:

root (hd0,

You will see something similar to the following:

grub> root (hd0,
Possible partitions are:
Partition num: 0, Filesystem type unknown, partition type 0×7
Partition num: 2, Filesystem type is ext2fs, partition type 0×83
Partition num: 4, Filesystem type unknown, partition type 0×7
Partition num: 5, Filesystem type is fat, partition type 0xb
Partition num: 6, Filesystem type is fat, partition type 0xb
Partition num: 7, Filesystem type unknown, partition type 0×82

Notice the ext2fs partition, this is the one Ubuntu is installed for the above example. I would therefore type:

root (hd0,2)

Now type the following, replacing hd0 with the physical drive Ubuntu is installed

setup (hd0)

Close the terminal, reboot and enjoy your restored GRUB loader.
Source: https://help.ubuntu.com