I upgraded to a 500GB hard-drive and installed windows 7 on it. I then moved my current ubuntu installation from the older HDD to the newer one on another partition, but of course there was no bootloader to load it. I had GRUB2 on older hard drive. I googled about how to recover GRUB2 but couldn’t find one. All I could find was solutions to fix corrupt Grub. So, I just reinstalled grub and then upgraded it to Grub2.
Here’s how to do it:
Boot into Ubuntu Live CD.
Mount the root disk (Disk on which Ubuntu is installed).
mount /dev/sda7 /media/root
where /dev/sda7 is your disk.
If you don’t know which disk the ubuntu is installed on, you can fdisk
sudo fdisk -l
Now, when you can install grub using grub-install
sudo grub-install –root-directory=/media/root /dev/sda –recheck
This will install the grub on the mounted disk. You can now reboot and get into your Ubuntu and upgrade it to GRUB2.
If this doesn’t work, you will have to change the root to the hard disk and install grub. To do that,
Unmount your boot partition (I’ll take sda7 as the example again) before proceding.
mount /dev/sda7 /mnt/root
mount -o bind /proc /mnt/root/proc
mount -o bind /dev /mnt/root/dev
You may need to run these as root/superuser. If successful, you’ll get the terminal access to your boot partition. You can now install the grub using apt-get.
apt-get install grub
But since, this is a new hard-drive, uuid won’t match. Hence, booting will fail.
To address this issue, you can install the grub2 without restarting
apt-get install grub2
Reboot. Grub2 should be installed now.