Restoring Grub2


If for some reason your grub has gotten corrupted, here are the steps to restore it.

Boot into a rescue CD (either Ubuntu or System Rescue CD, which you can download freely).

Mount the drive, where sdXY is the partition (eg: /dev/sda1)

sudo mount /dev/sdXY /mnt

Map all of system partitions (/dev, sys and proc):

sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys

Then "chroot" to the new directory:

sudo chroot /mnt

Note: if you are using System Rescue CD, you may get this error:
chroot: failed to run command `/bin/zsh` : No such file or directory

In that case you have to specify the shell:

chroot /mnt /bin/bash

Once chrooted, run the following to install grub (where sdX is your drive where grub will be installed. You have to use the drive, not a partition. ie: /dev/sda, not /dev/sda1)

grub-install /dev/sdX

Finally, unmount everything:

sudo umount /mnt/sys
sudo umount /mnt/proc
sudo umount /mnt/dev
sudo umount /mnt

and reboot.

Original article is posted on the ALT Technical site.