Monday 7 February 2011

Fixing Linux after installing Windows on dual boot system

My daughters are back to school this week so I decided I should install Windows 7 on a spare hard drive in my machine, as they say that sometimes they need to use Windows specific programs. In fact, one of their peers told me his IT homework consisted of following a step by step guide of clicking through a worksheet in a particular flavour of Office (I think it was 2010) and apparently he would fail by using any other version. If this is the case, its a sad state of affairs for IT learning but that's a whole other rant.

Up until now, I've been super happy with Linux, specifically Mint although I've played with Ubuntu, Fedora and Suse but figured if I don't install it now the night that they've got some assignment to complete, I'll have to go through the install pain so might as well have it ready.

Anyway in order to install Windows I had to unplug my main hard drive and leave just the soon to be Windows drive because apparently Windows has a drama if there is more than one drive present. This one drive had previously had Ubuntu on it. I booted from the CD and ran through the lengthy install process. Once it was all installed I rebooted a couple of more times to pick up any updates.
Then I plugged my other hard drive back in, expecting to just need to update Grub and all would be fine. However I found that Windows deletes or installs Master Boot Record which overwrites grub. I turned to Google and found this problem was well documented. After trying a number of solutions with no joy, I found that grub needed to be installed on the Windows hard drive as this was the first drive being accessed during boot up. The process to reinstall grub was to boot from the live CD (in this case Mint 10) then mount the disk with the Mint partition. In this instance my Mint install was on sdb, and windows on sda. The trick is to install grub to sda. The full instructions are:

sudo fdisk -l
sudo mount /dev/sdb6 /mnt
sudo grub-install --root-directory=/mnt /dev/sda
 
The first command lists your devices and you use this to work out which partition is your Linux installation. The second mounts that drive and the third funnily enough does the grub install. Note that we're installing grub on the first device, sda. After this a reboot and you should see the grub menu. If both partitions don't show up, boot into Linux and refresh the grub menu with

sudo update-grub

This worked perfectly for me with Linux Mint 10.