Sunday, June 20, 2010

Regaining windows boot after updating to Ubuntu 10.04

Cause

Grub was installed to the boot sector of the Windows System Partition. So when trying to boot Windows, the Grub code in the Windows boot sector is activated and the Grub menu appears. Sometimes Grub is not installed correctly, resulting in various different errors. Running the boot info script is an easy way to diagnose this problem. It will show the the "Boot sector type" of the Windows system partition as some version of Grub.

Solution

You can repair the boot sector of Windows system partition via "fixboot" from a Windows XP CD, or "bootrect /fixboot" from a Windows Vista/7 CD. But in my experience testdisk works best in this situation. So boot into a Linux OS or Live CD. If your system uses "apt-get" and has "testdisk" in its repositories (in Ubuntu: the universe repository needs to be enabled), you can install and run testdisk via
sudo apt-get install testdisk
   sudo testdisk
or you can download the tar.bz2 file of the newest version from testdisk to your desktop and install and run it via
cd ~/Desktop
  tar -xvf testdisk-*linux*.tar.bz2 
  sudo testdisk-*/linux/testdisk_static

In either case:
First   screen:  Select "No Log" and press enter.
  Second  screen:  Select the hard drive containing  the Windows system partition and  choose "proceed".
  Third   screen:  "intel"
  Fourth  screen:  "advanced",
  Fifth   screen:  Select the Windows system partition  and choose "boot"
  Sixth   screen:  "BackupBS"
  Seventh screen:  type "Y" to confirm
 
then press "q" a few times to quit testdisk, reboot and see whether you can boot into Windows. If the sixth screen did not have a "BackupBS" tab, it usually means that the original and backup boot sector are identical, and you are probably suffering from a different problem. But it could also mean that your backup boot sector is corrupted, in which case you will of to use "fixboot" from a Windows CD to repair the boot sector.
After you fixed the Windows boot sector, you might have to update the Grub Menu. For Grub 2 just run
sudo update-grub