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.

root@ubuntu:~$ mkdir /mnt/root
root@ubuntu:~$ mount -t ext3 /dev/sda6 /mnt/root
root@ubuntu:~$ mount -t proc none /mnt/root/proc
root@ubuntu:~$ mount -o bind /dev /mnt/root/dev

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

root@ubuntu:~$ chroot /mnt/root /bin/bash
root@ubuntu:~$ grub-install /dev/sda

Done.