Brian Vagnoni on 29 Nov 2007 03:30:57 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Can't seem to reinstall grub


What to do:
Put the redhat boot disk you created on the installation on the floppy drive, boot the system and run grub command

Remember that for grub (hd0,1) means hda (primary controller master), second partition.

Now we need to tell grub where are the grub files:

If you know where they are, type something like:
root (hd0,1)

else if you have no idea, type:
find /boot/grub/stage1
and then the root command with the correct parameters:

setup (hd0)
to install it on hd0, that is MBR of the first HD.

type quit and reboot.
The menu will appear again.
If you want to make some changes to the boot menu, you must edit the file: /boot/grub/menu.lst

A sample menu.lst file is this:

default=0
timeout=5
splashimage=(hd0,1)/boot/grub/splash.xpm.gz

title Red Hat Linux (2.4.18-14)
        root (hd0,1)
        kernel /boot/vmlinuz-2.4.18-14 ro root=LABEL=/ hdc=ide-scsi
        initrd /boot/initrd-2.4.18-14.img
title Red Hat Linux (2.4.18-openmosix3)
        root (hd0,1)
        kernel /boot/vmlinuz-2.4.18-openmosix3 ro root=/dev/hda2 hdc=ide-scsi
        initrd /boot/initrd-2.4.18-openmosix3.img
title WindowsME
        rootnoverify (hd0,0)
        chainloader +1

or

To repair it:
If you didn't create the boot disk, boot with the Red Hat Linux CD number 1 and choose rescue mode typing:
linux rescue

Now you need to repair the ext3 filesystem because now it's bigger than before and the journal file must be created again

First, check the filesystem:

fsck.ext3 /dev/hda2

Now, create again the journaling ext3 file:

tune2fs -j /dev/hda2

Now mount the root filesystem on /mnt/sysimage and run grub

mount -t ext2 /dev/hda2 /mnt/sysimage
cd /mnt/sysimage
cd sbin
grub

Once started, GRUB will show the command line interface. First, set the GRUB's root device1 to the boot directory, like this:
grub> root (hd0,1)
If you are not sure which partition actually holds these files, use the command find, like this:
grub> find /boot/grub/stage1
This will search for the file name /boot/grub/stage1 and show the devices which contain the file.

Note added by: John Neuhaus
If you are using a separate /boot partition, as the official documentation says:
"... if you have the partition /boot and you install GRUB images into the directory /boot/grub, GRUB recognizes that the images lies under the directory /grub but not /boot/grub"
Then if 'find /boot/grub/stage1' does not find the file, try 'find /grub/stage1'

Once you've set the root device correctly, run the command setup:
grub> setup (hd0)
This command will install GRUB on the MBR in the first drive.

and or to make a grub boot floppy
When you need to reinstall GRUB you can boot with your distro CD and enter in rescue mode, but you can avoid this and reinstall GRUB faster by just making a GRUB boot floppy disk.
You can create this disk right now and it will help you in the future, when problems knock your door.

You will need to know where are the files stage1 and stage2, in Red Hat they are on: /usr/share/grub/i386-redhat/
Other distributions keep it on /usr/lib/grub/i386-pc/ and if you don't know where it is, just find it:
find / -name 'stage1'

Once located, enter into the directory, put a floppy disk on the drive (do not mount it) and type:
cd /usr/share/grub/i386-redhat/
dd if=stage1 of=/dev/fd0 bs=512 count=1
dd if=stage2 of=/dev/fd0 bs=512 seek=1
Now your GRUB disk is created. Remember that this disk is not mountable, it's just a boot image, so if you want to verify it by mounting, errors will appear. Just try to boot with this disk to check if it's working.




___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug