Restore GRUB in Ubuntu after installing Windows

So, you had Ubuntu (or any of its derivative) installed on your system and then decided to install Windows with it? And after installing Windows, you can’t load Ubuntu again, just follow the steps to get this working:

  1. Boot the system using a Ubuntu Live disk.

  2. After you reach the desktop, open Terminal (press Alt+F2, type “gnome-terminal” without quotes and press enter).

  3. Execute:

```
sudo fdisk -l
```
  1. Execute (after replacing sda7 with your corresponding linux root partition, which you will be able to identify from the output of the previous command - it’s usually marked as Linux):
```
sudo mount /dev/sda7 /mnt
```
  1. Just check whether you got the root partition right, if you have more than 1 linux partition on your hard disk:
```
cd /mnt
ls
```

If the listing contains names like bin, boot, dev, etc, home, tmp, usr, var, et cetera then you are in the right partition. If not, unmount this using: sudo umount /mnt and follow the above step again using another partition.

  1. Now:
```
sudo grub-install --root-directory=/mnt /dev/sda
```

and grub will get installed if it shows no errors.

  1. As a last step unmount your /mnt directory using:
```
sudo umount /mnt
```

and restart the system. You will find the friendly grub boot manager giving you the choice to boot into Linux or Windows.

An edited version of this post first appeared at http://www.digimantra.com/linux/restore-grub-in-ubuntu-after-installing-windows/

– Kartik - The TechGlider Guy http://www.techglider.in

Posted with tags boot commands Disk partitioning gnu/linux Informative Linux Microsoft Windows Mount (Unix) Sudo terminal ubuntu Windows