grub-install question

Place to discuss Fedora and/or Red Hat
Post Reply
User avatar
Calum
guru
guru
Posts: 1349
Joined: Fri Jan 10, 2003 11:32 am
Location: Bonny Scotland
Contact:

grub-install question

Post by Calum » Fri Sep 15, 2006 6:29 pm

ok dudes...

using a fedora core 4 rescue CD, can i install grub on hd0 considering i have a fedora core 4 install on /dev/hda3 ?

if so, how?

thank you all...

PS: i can't boot from my floppy drive since the internal one is goosed, and the USB one won't boot. this means tomsrtbt is right out, sadly.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Fri Sep 15, 2006 6:48 pm

Is your "/boot" directory on /dev/hda3? I usually have 2 linux partitions "/boot" and "/". But if /boot is on your "/" partition and that is /dev/hda3 then this is what I usually do:

1) Boot your rescue CD (boot: linux rescue)
2) Mount your "/" partition if it didn't mount it automatically in rescue mode:

# mkdir /mnt/sysimage
# mount /dev/hda3 /mnt/sysimage

3) chroot to this:
# chroot /mnt/sysimage

4) install grub (assuming your /boot/grub/grub.conf and /boot/grub/device.map are correct)
# grub-install

5) Reboot
# exit
# exit

User avatar
Calum
guru
guru
Posts: 1349
Joined: Fri Jan 10, 2003 11:32 am
Location: Bonny Scotland
Contact:

Post by Calum » Sat Sep 16, 2006 1:47 am

yes, /boot is on /dev/hda3 as well, but the problem with doing the above (which is what i tried) (except that you have to do "grub-install hd0" ;-) )is that it then takes a few moments then tells me that /dev/hda3 can't be found, which is odd, since i didn't specify hda3 in the command line, and there's no explicit reference to it in grub.conf. I seem to remember doing this fine a few times before, but i believe this was something i was doing with tomsrtbt, not the fedora rescue CD. If i could find my actual Fedora install DVD, then i could slap it in and do a repair or rescue r some such thing, and it gives you an option to reinstall the boot loader, but i can't for the life of me find it anywhere. hang on a minute and i'll try it again, and let you know what the real error message is.

User avatar
Calum
guru
guru
Posts: 1349
Joined: Fri Jan 10, 2003 11:32 am
Location: Bonny Scotland
Contact:

Post by Calum » Sat Sep 16, 2006 3:00 am

well!

i did do all that again, in an effort to reproduce my error message and this time it appeared to hang for (i'm not exaggerating) fifteen minutes maybe, than told me it was done with no errors!

so it's fixed now, no idea why, but there we go!

very odd since i did try a couple of other boot CDs (you can get a command prompt on one of the virtual terminals if you boot from a suse or mandrake install disk too) and got the same error about /dev/hda3 so i have no idea what's going on there.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sat Sep 16, 2006 6:07 am

This "hang" is a common issue and it has to do with your /boot/grub/device.map (which I actually mentioned and you must have overlooked). I am also pretty sure I have discussed it on these forums before. I suspect your device.map looks like this:

Code: Select all

(fd0)     /dev/fd0
(hd0)     /dev/hda
It is trying to access your floppy drive which isn't accessible that is causing the big delay. If you make it look like this:

Code: Select all

#(fd0)     /dev/fd0
(hd0)     /dev/hda
the delay will not happen, the "grub-install" command will run instantly, and you don't need to pass the "hd0" param by the way. I have done this probably a hundred times.

User avatar
Calum
guru
guru
Posts: 1349
Joined: Fri Jan 10, 2003 11:32 am
Location: Bonny Scotland
Contact:

Post by Calum » Sat Sep 16, 2006 9:50 am

well, when i try to invoke grub-install on its own it always complains that i have to specify a device name!
[root@harvey ~]# grub-install
install_device not specified.
Usage: grub-install [OPTION] install_device
Install GRUB on your drive.

-h, --help print this message and exit
-v, --version print the version information and exit
--root-directory=DIR install GRUB images under the directory DIR
instead of the root directory
--grub-shell=FILE use FILE as the grub shell
--no-floppy do not probe any floppy drive
--force-lba force GRUB to use LBA mode even for a buggy
BIOS
--recheck probe a device map even if it already exists

INSTALL_DEVICE can be a GRUB device name or a system device filename.

Report bugs to <bug-grub@gnu.org>.
also, you are right about the device map, though i expected the delay because of past experience, but that wasn't the problem i was havining initially, it was that error message which i was unable to reproduce this morning which foxed me so much. anyway, i've commented out the floppy drive now as per your suggestion and ran grub-install again taking no time at all.

thanks for your time void main, much appreciated as always.
Last edited by Calum on Sat Sep 16, 2006 9:53 am, edited 1 time in total.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sat Sep 16, 2006 9:52 am

Duh, I had a brain freeze. You are right about passing the device. I always use this syntax though:

# grub-install /dev/hda

Either way will work though. I guess it's just so automatic when I type the command I don't even think about the parameter. Sorry about that! :)

worker201
guru
guru
Posts: 668
Joined: Sun Jun 13, 2004 6:38 pm
Location: Hawaii

Post by worker201 » Sun Oct 01, 2006 10:29 pm

I had to do a Windows reinstall (same old story) on my dual-boot machine today, and of course it totally rewrote the MBR. So I booted with my FC5 dvd and did the whole Linux rescue thing. Would using grub-install have worked for me? I didn't think of that. Here's what I ended up doing:

(note that the linux rescue features of the FC5 dvd will automatically mount your sysimage for you, no need to do that by hand)

# chroot /mnt/sysimage
# grub
grub> find /boot/grub/stage1
grub> root (hd1,0)
grub> setup (hd0)
grub> quit
# vi /boot/grub/grub.conf
# exit
# exit

My understanding of the events outlined above is this: you enter into a sort of grub command shell, tell it which drive has the /boot directory (hd1 in my case), and then write to the drive that contains the MBR (hd0). This worked for me. The 'find' command was great, because I didn't know exactly which disc was the right one - it figured it out for me. After this, everything worked just fine again. Now Windows is happy in its ignorance of a superior OS located on the same computer. :)

Fun note: this doesn't work if your fstab isn't correct. I had deleted a vfat partition that I used to transfer files around (back before NTFS support), but forgot to inform Linux of the change. Rescue won't mount your system properly if it doesn't like your fstab. Fortunately, I was able to access fstab from the rescue console and delete the offending line. After that, things were okay.

Fun note #2: trying to fix grub by running through the upgrade process doesn't quite work either. Anaconda notices that your grub is gone, and goes through the grub setup dialogue like normal. But then at the end, since no packages are being upgraded, the grub changes are aborted. Personally, I think Fedora ought to jam the grub rebuilder into the install process. You know, on the screen where it asks if you want to install or upgrade - have it ask if you want to install, upgrade, or just fix grub. Then "gurus" like myself could fix grub graphically.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sun Oct 01, 2006 10:36 pm

Yes, after booting FC5 rescue and letting it mount the partitions you should have just been able to:

# chroot /mnt/sysimage
# grub-install /dev/hda

User avatar
Calum
guru
guru
Posts: 1349
Joined: Fri Jan 10, 2003 11:32 am
Location: Bonny Scotland
Contact:

Post by Calum » Mon Oct 02, 2006 4:45 am

if i had had my install DVD to hand i would have done something like this, but i still can't find it anywhere, hence my need to get it sorted using a rescue CD.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Mon Oct 02, 2006 7:54 am

Calum wrote:if i had had my install DVD to hand i would have done something like this, but i still can't find it anywhere, hence my need to get it sorted using a rescue CD.
I don't think there is any difference between the install and rescue CD for this. In both cases you should be able to type "linux rescue" at the boot prompt and get the same thing (I'm nearly certain of it).

User avatar
Calum
guru
guru
Posts: 1349
Joined: Fri Jan 10, 2003 11:32 am
Location: Bonny Scotland
Contact:

Post by Calum » Mon Oct 02, 2006 10:28 am

well, the difference was i only had to download 90MB (or something) instead of a whole DVD. in fact i don't have the disk space for a whole DVD image and haven't set up XCDroast to do DVDs so the rescue CD was a godssend!

Post Reply