Sometimes happens to "break" the GRUB and make our computer unbootable or, anyway, not booting the way we want it to.
Usually this happens when we test/install a new operating system or maybe simply because we are "playing" with the GRUB.
NB: I'm going to explain how to restore GRUB 2 (tested on Ubuntu Lucid). For how to restore/fix GRUB 1, here is a good starting point.
So, let's get going. My favourite procedure is using Ubuntu Live CD.
So, once Ubuntu live OS is up and running we can start...
Let's create a directory where to mount the Ubuntu file system we want to fix the GRUB for.
sudo mkdir /mnt/newroot
Now we have to mount our hard drive/partition under the "newroot" directory just created:
sudo mount /dev/sdxy /mnt/newroot
where "/dev/sdxy" is our device name.
Then we need to mount some system directories under our "newroot" with:
sudo mount ‐‐bind /dev /mnt/newroot/dev sudo mount ‐‐bind /proc /mnt/newroot/proc sudo mount ‐‐bind /sys /mnt/newroot/sys
This needs to be done in order to make them available under our "newroot" too.
We are now ready to change the apparent root directory with:
sudo chroot /mnt/newroot
The "hard" part of the job is done. Now we can easily install and update the GRUB like if we were running the OS on the hard drive (rather than the live cd as we actually are).
sudo grub-install /dev/sdx
(where "/dev/sdx" is the device name) and
Hope it helps! :-)