Thursday, 31 March 2011

Dual Booting Blues?

It's been a while since I wrote anything. Not because I didn't have anything to say, just I didn't have the time to really write anything.

However, today I decided I would write THIS down. It's information that was gleaned from different sources and finally helped work the issue out. None of the places I read had the FULL steps to fix the issue. Hopefully this will help a poor soul.

Yesterday, someone installed Ubuntu on their system when I wasn't locally around to help out. They've installed Ubuntu on their home PC and on another desktop without really encountering any issues. That wasn't the case yesterday.

Somehow, the installation had frozen and they had therefore canceled it in mid-stride. They then reran the installer but manually selected the partition where they wanted to install (the one previously created/resized during the first install attempt.) Luckily they didn't wipe the Windows partition which they still needed, however booting into the machine was now not possible.

Investigating the issue I discovered that os-prober didn't see the Windows files it needed to boot. I went ahead and updated the system in case there were any fixes included in one of the updates. However, it seemed that the boot information for Windows was gone.

I was going to run something to recover the boot manager, but I wanted to be there to be able to troubleshoot things.

When I arrived at the office, I found out that they had taken things into their own hands and had used a Windows 7 install disk to "fix the boot manager" which in turn broke grub2 and now he couldn't boot into Windows 7 OR Ubuntu.

He could boot into the USB stick with Ubuntu, so quickly I did the following.

sudo fdisk -l
sudo mount /dev/sda5 /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
grub-install /dev/sda
grub-install --recheck /dev/sda
sudo umount /mnt/dev/pts
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt/sys
sudo umount /mnt
sudo reboot

This fixed the grub bootloader and we were now able to boot into Linux once more. However, During the update-grub, the Windows partition wasn't added to the loader. (This information came from Ubuntu's Help site.

Once in Ubuntu, I opened a terminal and did:

sudo fdisk -l
sudo mount -t ntfs /dev/sda1 /mnt
ls /mnt/boot
sudo update-grub
sudo umount /mnt
sudo reboot

Ok, in reality I initially mounted the Windows partition and checked that the files which were missing (BCD, BCD.log, etc) were there. Then I unmounted the Windows partition, ran os-prober which didn't detect Windows. So I then mounted the partition, re-ran os-prober and it DID find the Windows installation. At that point I ran update-grub which added the Windows information to the grub.cfg file and voila!

The things I had to "put together" were:

1. os-prober seems to need the Windows partition mounted when you run it manually. Not sure why it doesn't seem to need it when Ubuntu runs updates. Maybe it takes care of that itself.
2. The Windows 7 (and Vista) Boot Manager needs the files in the C:\boot\ directory to boot and os-prober needs those files to detect Windows 7/Vista.

I hope these steps help people out.

Post a Comment