View Full Version : [kubuntu] A 9.10 simple update/ugprade erased my Windows boot sector

January 14th, 2010, 05:19 PM

All I performed was a “sudo apt-get update” followed by a “sudo apt-get upgrade” and it wiped out the boot sector (not sure that is the correct terminology, boot sector, MBR, whatever) of my Windows drive. Now my Windows drive will only boot when the Ubuntu drive is available. Now that is a nice undocumented upgrade feature, not asking me permission to do this! How do I fix this without reloading Windows?

Here is my exact setup:

I have two physical hard drives. On Drive “A” I have Windows XP loaded. On drive “B” I have Ubuntu 9.10 64 bit loaded. They are (or should I say were) completely isolated entities. I like this much better than dual booting by putting everything on one drive, because I change operating systems quite a bit in order to experiment with them. I select the drive (and therefore the operating system) that I want to boot from by pressing the “F10” key that is available via the BIOS during boot up. The BIOS also allows me to select which drive to boot from by default.

Here is what happened:

I did an update and upgrade of Ubuntu in order to get the latest versions of all programs, and it overwrote the boot portion of the Windows XP drive. Ubuntu now controls everything, and forces me to boot through its boot program located on the Ubuntu drive. I verified this is what happened by disconnecting the Ubuntu drive. When I try to boot via the Windows standalone drive it no longer boots, and a Grub error occurs.

I have another computer with Windows 7 and Centos Linux loaded using the same exact technique, and this has never happened during an update (using yum).

My questions are:

1) Rather than restoring Windows XP from a bare metal restore backup (which I do have thank God), is there an easy way to recover the Windows XP boot sector?

2) How can I prevent this from happening again? If this is not possible, I am going to replace Ubuntu with Fedora, Centos or something else which behaves much more reasonably.

January 14th, 2010, 06:43 PM
You can easily reinstall the windows xp bootloader. There are multiple ways. Either from the XP cd or from Linux.

Using XP cd.
How to restore the Ubuntu/XP/Vista/7 bootloader (Updated for Ubuntu 9.10)
from ubuntu:
sudo apt-get install lilo
sudo lilo -M /dev/sdX mbr
It is a basic XP style boot loader that will work but windows may want to do repairs afterward.

I have seen several others with your problem. This was one solution. Grub seems to install to the first drive, so was your internal still listed as the first drive even though you booted from the external?
This reinstall of grub lets you choose which drive to install to. You need to know which drive is sda & sdb as that will be the choice. It also asks for special setting to put into the grub config file which unless you have special settings ( video or startup, etc) you can just accept.

reinstalls grub and allows choice of which drive to install to. Choose boot drive if not sda

sudo dpkg-reconfigure grub-pc
I finally found out how to prevent the MBR to be overwritten.
I ran dpkg-reconfigure grub-pc and deselected /dev/sda which meant that the values field for grub-pc/install_devices in /var/cache/apt/config.dat is now empty. Then nothing is written to the MBR or the boot sector when grub-pc gets updated. Occasionally I should probably rerun manually grub-install /dev/sda2 after grub-pc package updates to keep stage1 install in sync.

January 19th, 2010, 04:57 PM
I reloaded windows from my backup. I am done with Ubuntu.......no operating system should behave like this. It has a very poor user interface anyway. I guess if I was looking for a Windows clone it would be OK. I am more of a command line or simple menu based interface favoring person, used to mission critical based UNIX/Linux operating systems. I just wanted to try Ubuntu out. Its back to Centos or Fedora for me.