When you install Windows, Windows assumes it is the only operating system (OS) on the machine, or at least it does not account for Linux. So it replaces GRUB with its own boot loader. What you have to do is replace the Windows boot loader with GRUB. I’ve seen various instructions for replacing GRUB by mucking around with GRUB commands or some such, but to me the easiest way is to simply
chrootinto your install and run
chrootis great because it allows you to work on your actual install, instead of trying to redirect things here and there. It is really clean.
- Boot from the live CD or live USB, in “Try Ubuntu” mode.
- Determine the partition number of your main partition. GParted (which should already be installed, by default, on the live session) can help you here. I’m going to assume in this answer that it’s
/dev/sda2, but make sure you use the correct partition number for your system!
Mount your partition:
sudo mount /dev/sda2 /mnt #Replace sda2 with your partition number
Bind mount some other necessary stuff:
for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done
chrootinto your Ubuntu install:
sudo chroot /mnt
At this point, you’re in your install, not the live session, and running as root. Update grub:
If you get errors, go to step 7. (Otherwise, it is optional.)
Depending on your situation, you might have to reinstall grub:
grub-install /dev/sda update-grub # I'm not sure if this is necessary, but it doesn't hurt.
If everything worked without errors, then you’re all set:
exit sudo reboot
At this point, you should be able to boot normally.
If you cannot boot normally, and didn’t do step 7 because there were no error messages, try again with step 7.
The terminal way
* Open a terminal. As of Ubuntu 11.10 and 11.04, this can be done by opening the Unity Dash (you can click the Ubuntu logo in the top panel or use the Windows key on your keyboard) and typing in “Terminal”, and clicking what comes up. On earlier versions, you can achieve this by going to Applications -> Accessories -> Terminal. Alternately use the Keyboard Shortcut: CTRL + ALT + T.
sudo grub-install /dev/XXX
where XXX is the device of your Ubuntu install. (eg: grub-install /dev/sdb). Hint: You can also use /dev/disk/by-label/ if the partition you installed on has a label. You can determine the /dev node for such a device by running:ls -l /dev/disk/by-label/
You can also use fdisk if you do not see the /dev/disk/by-label:$ sudo fdisk -l