Newbie novice installed Grub on Redhat 7.3 with separate /boot partition, dual boot Windows XP

Newbie novice installed Grub on Redhat 7.3 with separate /boot partition, dual boot Windows XP

Post by Thomas Fray » Sat, 14 Sep 2002 11:55:24



I installed Redhat 7.3 Linux plus Win4Lin 4.0 to use Grub as the boot
loader for dual boot with Windows XP on a system with 4 SCSI hard
drives.  The /boot directory was on a separate partition.   Later I
added a Data Express IDE hard drive enclosure to allow mounting
removable IDE hard drives, and bought a 40 GB and a 100 GB hard drive
to mount in the enclosure.  I had booting problems after doing this,
starting with the fact that my Aopen AX6BC motherboard with Award BIOS
would not let me change the boot sequence, so the MBR had to be on the
mounted removable hard drive.  I decided to install Grub on each
removable hard drive.  How I did this is a long story, but I'll tell
the short version first.

After logging on as root, I created the /boot/grub directory and
copied to it:
        /usr/share/grub/i386-redhat/*, /etc/grub.conf, /sbin/grub
I executed:
        cd /boot/grub
        ./grub
This activated the grub shell.  I issued the grub command:
        setup (hd0)  (hd2,0)
The response was
        Checking "/boot/grub/stage1"  no
        Checking "/grub/stage1"               yes
        Checking "/grub/stage2"               yes
        Checking "/grub/stage1_5"             yes
        Running "embed/grub/e2fs_stage1_5 (hd0)"              22 sectors are embedded
        Running "install /grub/stage1 d (hd0) (hd0)1+22" p (hd2,0)/grub/stage
2 /grub/grub.conf
I executed
        quit
and rebooted.  The Grub boot menu was displayed, and operated
correctly.  End of the short version.

If it's this easy, why bother writing this note?  Well, I spent two
days and multiple tries to figure out how to do it, so I thought
others might benefit from my experience.

From the Grub Manual,
http://www.gnu.org/manual/grub/html_mono/grub.html, the setup command
syntax is:

setup [--force-lba] [--stage2=os_stage2_file] [--prefix=dir]
install_device [image_device]

Thus (hd0) specifies the install_device as disk 0, which starts with
the MBR, and (hd2,0) specifies the image_device, which is the boot
partition, which is mounted at /boot.  (hd2,0) is partition 0 on drive
2.  The Grub names
(hd0)   (hd1)   (hd2)   (hd3) ...       (hd2,0) (hd2,1) ...
correspond to Linux names
hda     sda     sdb     sdc ...         sdb1    sdb2 ...

The response to the setup command indicated that there was no /boot
directory on the image device, which is the boot partition, (hd2,0),
but that this partition contains the needed files in the /grub
directory.  It took several iterations for me to discover that the
boot partition is treated as the root directory by Grub.  I think that
if I had specified (hd2,1), which is my root partition, as the image
device, the setup command would have found the /boot/grub/* files via
the root directory and the mounted /boot directory.  This is the way a
user without a separate boot partition would do it.

Next, setup embedded the Stage 1.5 file for the ext2 file system in
the 22 sectors after the MBR.  Finally, it installed stage 1 in the
MBR, with stage 1.5 in the next 22 sectors, and stage2 and grub.conf
left where they were.  It patched the installed stage 1.5 with
pointers to stage2 and grub.conf, I think.  (The description is under
the install command in the Grub Manual, but I haven't been able to
discover how the description fits the command issued by setup.
Perhaps p stands for patch, and the remainder of the setup command is
just copied after the 22 sectors.)

At boot time, after BIOS and SCSI BIOS have done their things, the MBR
is loaded and given control.  It is only 512 bytes, so all it can do
is load the first sector of stage 1.5, and give it control.  The first
sector of stage 1.5 loads the rest of stage 1.5, which loads stage 2,
and gives it control.  Stage 2 executes and interprets grub.conf,
which controls the rest of the boot process.

grub.conf was set up during my original install of Linux, and modified
during installation of Win4Lin.  It displays a menu allowing me to
boot the original Redhat kernel, the Windows XP boot loader, or the
Win4Lin kernel.

My big problem was starting off with the wrong manual.  The GNU GRUB
Boot Loader LG #64 does not mention the setup command, and has an
incomplete description of the install command.  Time after time, I
studied the document, tried to guess at what it meant, and tried doing
the install, only to get a system that would not boot.  At one point,
I got the Grub shell booted.  The next boot I had enough information
from the grub.conf file to manually enter the root, kernel, initrd,
and boot commands, and I successfully completed the boot.  However, I
was unable to find a way to have the grub.conf file executed by the
boot loader.  At this point I found the Grub Manual,
http://www.gnu.org/manual/grub/html_mono/grub.html.  Even though the
install command description advises using setup, I continued trying to
find a way to use install, without success.  When I finally switched
to setup, success came very quickly.

I have no idea whether what I came up with is the best solution, but
it worked.  It seems to me that there should be a GUI (graphical user
interface) for installing or re-installing Grub, but I was unable to
discover one.  The Redhat install procedure includes a Grub GUI, so it
should be trivial to build one to be invocable from Gnome.  Does
anyone know of an existing GUI?  If not, I'll try to build one myself
when I've had more than two weeks experience with Linux.