[opensource] My Windows ran over my GRUB

William Triest triest.1 at osu.edu
Tue Nov 28 18:30:54 EST 2006


>>
>> When I installed Ubuntu, I left the first partition /dev/sda1 empty in
>> order to later install winxp, which I hear really likes to be on the
>> first partition.   Linux booted fine (I think grub was resident in the
>> MBR)
>>
>> Now that windows is installed, it will only see itself to boot, and
>> grub is no more.
>>
>> I'd rather use grub, if at all reasonable, just to play with the
>> interface and make it pretty.
You are exactly right, the mbr was overwritten.  One of the nice things 
about grub is that all your settings live in a config file on your hard 
drive.  This means its really easy to re-setup grub.  I assume you can 
boot a live cd (come on, you're running ubuntu).  There may be an Ubuntu 
utilitiy to reinstall grub, I don't know.  The generic way would be to 
mount your partitions, chroot to where you mounted it, and then run 
grub-setup (or if that fails run grub and type the necessary commands).  
Since I'm a gentoo user, that's how I installed it in the first place.

Let's say
/dev/sda1 is windows
/dev/sda2 should be /
/dev/sda3 should be /boot
(other partitions may exist, but I'm trying to keep this simple)

Then mount the partitions
mount /dev/sda2 /mnt/tmp
mount /dev/sda3 /mnt/tmp/home

Then chroot into those directories
chroot /mnt/tmp

Try grub-install (it never seems to work for me).  If so that should be 
it.  If not, then run grub

Grub has a "shell" that runs.  Since the hard drive is hda, then if you 
have no sata or scsi it should be the first hard drive (hd0 in grub 
speak).   When you see hd0,0 that means the first partition of the first 
hard drive.  Under linux you have hda which is a parallel ata drive.  
Then you have sda which is sata, scsi, usb etc.  With grub, they are all 
hd, but the numbering is literally the order the bios sees them.  So if 
you have sda and hda then hda could be hd1 (although more hten likely it 
is hd0).  The comma seperate a hard drive from its partition.  To sort 
out which hard is which, I usually just tab auto complete and I am able 
to fairly quickly figure it out.

Assuming hd0 is sda then you should run
root    (hd0,1)
setup   (hd0)

Just so I can remember this in an emergency, I have an entry in my 
grub.conf with the correct info.  That way I boot the live cd, mount, 
and can tail my grub.conf to know what I need to do.

Finally, add windows to grub.  Edit /boot/grub/menu.lst (that's a 
lowercase L, commonly the file is a symlink to /boot/grub/grub.conf   Or 
not, on gentoo I just have a grub.conf, but I really thought menu.lst 
was the proper file.  Google it or read the info file if you really want 
to know)

At the very bottom add:
# For booting Windows NT or Windows95
title Windows
rootnoverify (hd0,0)
makeactive
chainloader  +1

If you need more info googling really should solve it (which is probably 
quicker then waiting for a response).  Obviously I'm happy to clarify 
any steps or explain what they're doing better.  Also if some one sees 
any errors, please correct.  I've been under the weather lately, so 
thinking straight isn't my strong point at the moment.

--Bill


More information about the Opensource mailing list