-   Linux - Newbie (
-   -   Grub boot loader (

dubya 03-22-2004 11:24 AM

Grub boot loader
I recently reinstalled Windows XP on the same partition as it was before with RedHat 9.0 on the other. However, now when I restart my computer, it skips the bootloader and boots right into Windows XP. Does anyone know how I can get the bootloader to come up again everytime I restart without having to reinstalled RedHat? Thanks in advance.

forrestt 03-22-2004 12:55 PM

The problem is that the Windows XP install over-wrote your boot sector. To replace it so that grub launches instead of the XP boot loader, you need to do the following.

Put your linux install CD into the drive and boot from it. At the boot prompt type:

linux rescue

When you get a command prompt, type:

% chroot /mnt/sysimage

Now type:

% /sbin/grub-install /dev/hda

Note: /dev/hda is probably correct, but you may need to change /dev/hda to whatever drive you boot from. Consult the following guide:

Primary Master /dev/hda
Primary Slave /dev/hdb
Secondary Master /dev/hdc
Secondary Slave /dev/hdd
Tertiary Master /dev/hde
Tertiary Slave /dev/hdf
Quaternary Master /dev/hdg
Quaternary Slave /dev/hdh

If you are using scsi, then you will need to put the /dev/sd? of your scsi device.

Hope this helps,


dubya 03-22-2004 07:34 PM

It said I was unable to change the root directory after that first command. I can boot into RedHat fine with a boot floppy disk. Is there a easier way to do it from RedHat? Thanks for your help.

sirpimpsalot 03-22-2004 07:42 PM

simplest method.... boot to a dos or windows 9x floppy and type


rewrites the master boot record.

Brane Ded 03-22-2004 08:41 PM

fdisk /mbr won't restore his bootloader.


It said I was unable to change the root directory after that first command. I can boot into RedHat fine with a boot floppy disk. Is there a easier way to do it from RedHat? Thanks for your help.
Get to a command line, and type "grub-install /dev/hda" like forrestt said, replacing hda with the appropriate device.

dubya 03-23-2004 12:46 AM

Thanks for your help everyone. As root, grub-install /dev/hda did it. Thanks again.

ruzer 04-30-2004 10:18 AM


I have a similar problem, but I don't have a floppy drive or a rescue disk. I booted up from knoppix, and can access my hard disk partitions, but i can't get grub to install back on the mbr. Here's what happens:

root@ttyp0[/]# chroot /mnt/hda4 grub-install /dev/hda
/dev/hda does not have any corresponding BIOS drive

I think it might be because I booted from knoppix so /mnt/hda4/proc is empty, whereas /proc/ is full of stuff (i presume from the knoppix boot process)

Does anyone know what to do?


forrestt 04-30-2004 10:29 AM

The command needs to be separated (Not sure if you did this correctly and typed it differently in the post, or if you didn't do it correctly). It should be:

root@ttyp0[/]# chroot /mnt/hda4
root@ttyp0[/]# grub-install /dev/hda

However, hda might not be correct. See my above post regarding drive assignments. If you do:

root@ttyp0[/]# ls /mnt/hda4

do you see your system? If you do, then hda is correct. If you do not, then you need to determine where your system is really located.

Another thing you might want to try is to copy all of the grub stuff from your real systems /etc to /etc on the knoppix system. After it is all copied, then run the grub-install command and see if that works. I have never done it that way before, but it might work. Post back and let me know how things are working.


ruzer 04-30-2004 10:46 AM

i separated the commands, and i get the same

root@ttyp0[/]# chroot /mnt/hda4
bash-2.05b# grub-install /dev/hda

when i run:
root@ttyp0[/]# ls /mnt/hda4

it lists all the system folders, so this is where the actual system is.

First I copied from /mnt/hda4/etc/ to /etc/

Then i tried to run grub-install /dev/hda4, and I got the same error as before, (no matching device in BIOS, or something similar)

Then I tried to copy from /proc/* to /mnt/hda4/proc/ and the a few files were copied, and then the system just hung(!)

Can I tell grub-install to use the /proc folder of knoppix?

Is there a gentoo rescue image i can download anywhere?


forrestt 04-30-2004 10:57 AM

run the mount command
root@ttyp0[/]# mount

and look for the line that lists /mnt/hda4. is the device that is mounted there /dev/hda4 or something else? If it is something else, replace that with the /dev/hda in the grub-install command, but leave off the 4. If it is /dev/hda4, then write back and I'll see if I can come up with something else.


ruzer 04-30-2004 11:04 AM

it is /dev/hda4 !

Full listing:

/dev/root on / type ext2 (rw)
/dev/cdrom on /cdrom type iso9660 (ro)
/dev/cloop on /KNOPPIX type iso9660 (ro)
/ramdisk on /ramdisk type tmpfs (rw, size=611168k)
usb on /proc/bus/usb type usbdevfs (rw,devmode=0666)
automount(pid403) on /mnt/auto type autofs (rw, fd=4,pgrp=403,minproto=2,maxproto=4)
/dev/hda4 on /mnt/hda4 type reiserfs (rw, nosuid, nodev)
/dev/hda1 on /mnt/hda1 type ext2 (rw, nosuid,nodev)


forrestt 04-30-2004 11:30 AM

Is grub configured to load into the mbr or the first partition? If it is in the partition, then the problem might be the nodev option for /dev/hda1 (although I'm not super familiar with that option). Try remounting it without the nodev option

root@ttyp0[/]# umount /dev/hda1
root@ttyp0[/]# mount /dev/hda1 /mnt/hda1

Let me know,


ruzer 04-30-2004 11:43 AM

i unmounted and then mouted as you said, but grub-install /dev/hda still gives same error

here is the grub.conf file that is located at /mnt/hda1/grub:

default 0
timeout 5

title=Linux 2.4.25-gentpp-r2
root (hd0,0)
kernel /vmlinuz-2.4.25-r2 root=/dev/hda4

chainloader +1

Does this tell you where its configured to load?

forrestt 04-30-2004 12:35 PM

Apparently this is a problem with gentoo. Here is a link to the chapter on installing the boot-loader in gentoo:

Basically they want you to install grub with the interactive grub shell.

Hope this helps.

ruzer 05-04-2004 07:40 AM

hey forrestt,

thanks for all your posts- i'll give this a go later on and report any successes


All times are GMT -5. The time now is 07:18 AM.