Wednesday, May 25, 2011

Reinstalling GRUB Legacy after windows reinstall

After Windows reinstall the windows would overwrite the GRUB. If using Ubuntu 9.10 or later or have the GRUB2 installed then see here -

If using older GRUB legacy version then the situation is a little bit tricky but not hard. There are two ways to do this.

A) Use older LiveCD, possibly of Jaunty.

1. Make a bootable USB. Use unetbootin and not the Startup disk creator otherwise you will have the error

vesamenu.c32: not a com32r image


2. Boot into LiveCD.

3. Run grub

sudo grub

4. Find where Grub is.

grub> find /boot/grub/stage1
(hd0,5)

This may or may not be the correct partition where grub resides. If there is /boot partition in addition to a root partition then there might two locations where grub is installed for e.g. /dev/sda5/boot/grub and /dev/sda6/boot/grub. The one that contains the menu.lst is the one that is to be used. Figure out which one has this menu.lst file.

5. Then tell GRUB which partition your Grub is on by entering

grub> root (hd0,4)

Note the GRUb is really installed in /dev/sda5/boot/grub and not in dev/sda6/boot/grub as find claimed.

6. Commit it to MBR as well generate the boot menu. (Adding the kernel and initrd images manually is not needed.)

grub> setup (hd0)

should give a message that the menu is generated correctly. If the menu.lst is not found retry with other partitions.

7. Exit

grub> quit

B> Use newer LiveCD, like Maverick.

1. Make LiveCD. It does not have the syslinux problem.

2. Boot into LiveCD.

(next 3 points are from

3. Mount the /boot partition. Go to 'Places'-->'Removable Media' or just 'Places' and look under 'Computer' for the disk or partition you want to mount and click on it.

You should see an icon for it on your desktop, but what you may not see is the 'mount point', which will normally be located in your /media directory. We will need to know the file path and name of the mount point.

4. Find the name of the mount point,

ls /media

The file path that is returned from the above command will be needed for making up the next command. The name of the mount point might be a file system LABEL or UUID number. For my example I'll just use the word 'disk' for short.

5. Run the grub-setup command, inserting the -d option and specifying the path to the /boot/grub directory of the operating system you're trying to fix,

sudo grub-setup -d /media/disk/boot/grub /dev/sda

The -d option tells GRUB to use files from the specified directory.
Please substitute the word 'disk' with the name of your own mount point as found in step 3)
The '/dev/sda' part tells grub-setup to install GRUB to MBR in the first hard disk, which is called '/dev/sda'.
You may use the same command to install GRUB in any other disks in your computer by replacing the /dev/sda part of the command with /dev/sdb or /dev/sdc and so on.

- If the command fails with feedback about not being able to access a device.map file, you might need to try again and specify the exact device.map file to use with the -m option.
sudo grub-setup -d /media/disk/boot/grub -m /media/disk/boot/grub/device.map /dev/sda
The -m option tells GRUB what device.map you want to use.

6. Now, the GRUB2 is installed into MBR. But chances are that only stage 1.5 is installed and not the boot menu.

7. Reboot. If the menu shows fine otherwise it would drop to the grub> prompt. Then follow steps from A> 4. above onwards (finding the grub etc.).




No comments:

OK GOOGLE on Samsung Galaxy S7 doesn’t work

To make Ok Google detection work on Galaxy S7 (Galaxy series phones) we need to perform a couple of steps. 1. As long as Samsung S vo...