Reinstall grub using a Linux Live-CD

I just reinstalled Windows on my dual-boot system and had to reinstall grub as Windows setup overwrites the existing master boot record. Here’s how I did it using a Linux Live-CD (im my case an Ubuntu 7.04 CD I had lying around). My Linux root partition is /dev/sda6.

First it’s necessary to mount our Linux filesystem (including /proc and /dev). If you got /boot on an extra partition, you have to mount that partition too.

$ mkdir /mnt/root
$ mount -t ext3 /dev/sda6 /mnt/root
$ mount -t proc none /mnt/root/proc
$ mount -o bind /dev /mnt/root/dev

Then we can chroot into our system and re-install grub on /dev/sda.

$ chroot /mnt/root /bin/bash
$ grub-install /dev/sda