To recover the boot loader for Ubuntu Linux or any other linux after the boot loader has been erased due to a dual windows installation or some other reason.
We need a bootable CD or USB to boot into a Linux shell.
Once looged in a Linux shell on the same machine, these steps are to be followed.
1. mount the / (root) partition of the Linux installation for which the grub boot loader has to be resintalled.
2. chroot into the Linux environment
3. run grub-installation
So the following command were run for 1 case where I reinstalled the grub bootloader from the /dev/sda2 partition
1. mount /dev/sda2 /media/linux
2. chroot /media/linux
3. grub-install /dev/sda
during grub-install, I got a message similar to
‘grub-probe: error: cannot find a device for /. (in chroot)’
So I ran this command also before chroot
mount –bind /dev/ media/linux/dev
and then rest of the commands