Home page of this blog

Monday, November 29, 2010

Reinstalling grub after installing windows or after losing it

Recently my friend lost his grub after installing windows and he could not boot into Ubuntu. Long back we refered grub2 documentation from Ubuntu site and followed it to reinstall grub2. He asked me if I remembered it and I do

He asked me to post this as an article for his or anyone's easy reference and here it is for easy reference, if you lost your grub2 and unable to boot into any one of the following OS

 Ubuntu 10.04, Ubuntu 10.10, Linux Mint 9, Linux Mint 10, debian squeeze

His root ubuntu partition is in /dev/sda8 so I assume the reader of this article will take care to replace it with his root partition

Here are the steps to restore grub2 after your windows installation messes it up

Boot Ubuntu live cd (if you had installed 64 bit Ubuntu, then boot into 64 bit, otherwise use 32 bit, if u use a 32bit livecd to restore 64 bit or vice versa wont work!)

goto command line (use Applications --> Accessories --> Terminal or use Alt + F2 and gnome-terminal)

sudo mount /dev/sda<root partition number> /mnt

in my friends case it is sudo mount /dev/sda8 /mnt

sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys

sudo chroot /mnt

sudo update-grub


grub-install /dev/sda




sudo umount /mnt/sys
sudo umount /mnt/proc
sudo umount /mnt/dev/pts
sudo umount /mnt/dev
sudo umount /mnt

sudo reboot

No comments:

Post a Comment