Windows overwriting Linux bootloader

Q When I installed SUSE Linux Enterprise Desktop [SLED] 10, I made these partitions on my 28GB hard drive:

FAT32, 10GB, /windows/C.
Linux, 10GB, /.
FAT32, 7GB, /windows/E.
swap, 9GB, swap.

Then I installed Windows on C:. But now I have a problem: Linux is not booting. I do not get the menu that asks me to choose between the OSes; Windows starts directly. I should mention that when I was installing Windows it said something like, 'there is an unknown partition, it will be inactive, if you want to activate it do...', but when I went to follow its instructions it couldn't recognise that partition and now I have Windows with only two partitions, C: and D: (note that D: is the 7GB, not the 10GB). Is there an answer?

A This is a common problem, caused by the Windows installer's assumption that there are no non-Microsoft operating systems. When you install Windows it overwrites the bootloader with its own, without considering that you may wish to keep it. The good news is that your Linux installation is untouched, including the original bootloader menu and other settings. All you have to do is reset the hard disk's Master Boot Record to use the Grub bootloader that SUSE set up for you. Boot from the SLED CD/DVD and select the Rescue System option from the menu; this will boot to a login prompt. Type root at the prompt (there's no password needed) and you are in a basic rescue shell. The first step is to determine which is your Linux partition. Run fdisk -l to display a list of partitions. One of them will be marked as Linux - probably /dev/hda2 based on your list of partitions above. You can mount this partition with

mount /dev/hda2 /mnt

Then type the following commands to enter the Grub shell and find the correct partition for the bootloader:

find /boot/vmlinuz

This returns the boot disk in Grub's terminology, probably (hd0,1). Now type the following commands to set up the bootloader again:

root (hd0,1) #the disk label returned above
setup (hd0)

That's it, you can now reboot with the cryptically-named reboot command. Eject the CD/DVD and you should get your Grub menu back with the same choices as before. Note that if you ever need to reinstall Windows, the same will happen again - with the same solution.

Follow us on or Twitter

Username:   Password:
Create Account | About TuxRadar