How to repair GRUB with a live cd?

There are many things that could go wrong with a GRUB installation and one way to get the system booting is some kind of a live cd. sysrescuecd is highly recommanded as it has a ton of options for fixing a broken installation.

The main problem I had was getting GRUB to recognize the drives etc. correctly, when you boot from a live cd. There are a few things you need to keep in mind, so you can repair GRUB and other things in the first place:
 

1) mount the system into the live cd enviroment:

mkdir /mnt/system 
mount /dev/sdX /mnt/system

 

2) mount the proc and other special file system so your system will work properly:

 

mount -o bind /dev /mnt/system/dev 
mount -o bind /sys /mnt/system/sys
mount -t proc /proc /mnt/system/proc
cp /proc/mounts /mnt/system/etc/mtab 

 

3) after that is all done, you can chroot into the system and work with it and make repairs:

chroot /mnt/system /bin/bash 

 

From there you can make your way with update-grub and of cource grub-install /dev/sdX --recheck 

You cannot comment on this entry