Reinstall grub2 after installing windows 7 (XP/Vista)


You may need to reinstall grub when windows is installed after ubuntu (or if you reinstalled windows in dual boot (Windows and ubuntu) system). I used following steps for reinstalling grub in order to login to my Ubuntu 10.04 after reinstalling Windows 7 on my machine.
1. boot the ubuntu LiveCD
2. Open a terminal and type
sudo fdisk -l
This list the partition tables, and in my case root (/) partition is on /dev/sda9.

3. Mount that partition using following command.

sudo mount /dev/sda9 /mnt

4. Run the grub-install command as below. This will reinstall the grub 2

sudo grub-install --root-directory=/mnt /dev/sda

Here “sda” is the hard disk on which your Linux distribution is installed!

5. Reboot

6. Finally Refresh the grub 2 menu using following command
sudo update-grub

Now everything should be fine 🙂

Bình luận về bài viết này