grub: Re-install from recovery CD

This post describes how to install grub after the computer has been booted from a recovery CD.

Install GRUB again

After the computer has been booted from a recovery media, execute the following steps as root user:

Find out how your disks are named under the bootet Linux and mount it

fdisk -l
mount /dev/sdXY /mnt/  (replace sdXY with your disk, e.g. sda1)

Mount the existing virtual folder for proc, dev and sys from the booted linux system as folders into the mounted disk. Make sure you mount them into the folder you have mounted your disk – in this example /mnt.

mount -t proc none /mnt/proc
mount -o bind /dev /mnt/dev
mount -t sysfs sys /mnt/sys

No execute a chroot into the mount folder, in this example /mnt

chroot /mnt/ /bin/bash

Now you the envirement your are working on looks like and behaves like a system booted from the disk. The folders proc, dev and sys are shared from the system booted from cdrom, the other folders are the ones from your mounted disk. No you can update your grub configuration and install it – in this example it is installed into the MBR of the mounted disk.

update-grub
/usr/sbin/grub-install --recheck --no-floppy /dev/sda

Afterwards you need to sync the changes to the disk (so no unwritten will get lost) reboot the system.

sync && reboot

Done! Your system should boot again with the original settings configured.