Friday, August 6, 2010

Doing a Grub Repair from a Live Ubuntu CD


This was done using a Ubuntu 10.04 live CD.

This is the guide I followed:  


SystemRescueCD looks pretty good, but there is no need to use it if you have any live Linux CD with the correct tools.

SystemRescueCD didn't have a cool picture so I grab a general picture from here:  http://behdad.ws/post/681808291/rescue-cds

First you must know the '/' and '/boot' mount points.  '/boot' may not need to be mounted, if it is included under the root mount point.

To find this information use System => Administration => Disk Utility.  You can also get this information running 'fdisk -l' as root.

In my case the install was on a single partition on /dev/sda3.





ubuntu@ubuntu:~$ sudo mkdir /mnt/linux
ubuntu@ubuntu:~$ sudo mount /dev/sda3 /mnt/linux
ubuntu@ubuntu:~$ sudo mount -o bind /proc /mnt/linux/proc
ubuntu@ubuntu:~$ sudo mount -o bind /dev /mnt/linux/dev
ubuntu@ubuntu:~$ sudo mount -o bind /sys /mnt/linux/sys
ubuntu@ubuntu:~$ sudo chroot /mnt/linux /bin/bash
root@ubuntu:/# grub-install /dev/sda
Installation finished. No error reported.
root@ubuntu:/# exit
exit
ubuntu@ubuntu:~$ sudo umount /mnt/linux/{dev,proc,sys}
ubuntu@ubuntu:~$ sudo umount /mnt/linux
ubuntu@ubuntu:~$ 

Reboot the computer and Grub should now work.  The link to repairing a damage Grub gives a more detailed description.  It might also be good to read the section on Grub to understand how Grub works.

The reason this works is because the Grub information selecting the Linux and Windows boots is located in the /mnt/linux/boot folder and was never damaged.


Good luck.

No comments: