Friday, 10 February 2012

Recover Grub2 after Windows installation/repair.

After a Windows install or repair the Windows bootloader replaces Grub and so your system only boots in Windows.
Here is how you can recover the lost Grub2 bootloader.

*Note:- This tutorial assumes that there is still a linux partition present in the system and you haven't formatted it or installed Windows over it.

For this you will need to boot from the Ubuntu LiveCD (or Live USB).
Boot from the CD and select Try Ubuntu without Installing.

1. Open the terminal: Applications -> Terminal (shortcut key: Ctrl+Alt+T).

2. Type the command: sudo fdisk -l.
When it prompts enter your password.


3. Note which device contains the linux partition (/dev/sda3 in this case).

4. Type : sudo mount /dev/sda3 /mnt 
(I am entering /sda3 because it is the linux partition in my case. Replace sda3 with the linux partition for you)

5. sudo mount --bind /dev /mnt/dev

6. sudo mount --bind /proc /mnt/proc
7. sudo cp /etc/resolv.conf /mnt/etc/resolv.conf  (optional step)

8. sudo chroot /mnt

9. grub-install --recheck /dev/sda3 (again replace sda3 with your linux partition)
10. reboot

And there you have it, your Grub2 bootloader up and running.

No comments:

Post a Comment