[RHCE] my GRUB story

Jerry rhce@trilug.org
Wed, 10 Jul 2002 15:03:54 -0400


This is a multi-part message in MIME format.
--------------76C1E0D4DEB7D17F0529461B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello,
	I'm attaching a text file with my experiences with grub back in April.
I'm sorry I didn't remember more of this last night but you may still
find it helpful. Are attachments stripped by the listserv? I guess I'll
find out.

Jerry
-- 
Gerald W. Gordon, Ph.D.
Department of Cell and Developmental Biology
Taylor Hall, CB 7090
University of North Carolina
Chapel Hill, NC 27599

919/966-2941 (vox)
919/966-1856 (fax)
Gordon@med.unc.edu (email)
--------------76C1E0D4DEB7D17F0529461B
Content-Type: text/plain; charset=us-ascii;
 name="Dual Boot Linux W2k with GRUB.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="Dual Boot Linux W2k with GRUB.txt"

Dual Boot Linux and Windows 2000 Pro with GRUB

The system is an 800 MHz Pentium (Dell 4100) with single 30 GB disk.

Install Windows 2000 Pro on the first partition. When I had w2k on the second partition and tried to reinstall it, the install program wanted to copy files to the first partition but that wasn't possible since I had made the first partition a Linux partition. So my rule is to have the first partition always be formatted for windows.

Install Linux. On this system I made the windows partition small enough (6GB) that I could make a separate /boot linux partion that was entirely below cylinder 1023. This is probably not necessary with the GRUB supplied with redhat linux 7.2 but I was having trouble and eliminated one possible problem. During the linux install make a boot floppy and don't write the boot loader to the master boot record but to the linux / partition. This again is conservative. The boot floppy boots linux in case something goes wrong. Leaving the windows boot record in the MBR alone allows booting windows if something goes wrong. (However, even if the MBR is trashed it can be restored with fdisk /MBR.) The short way to do it is to select GRUB as the bootloader and write it to the MBR, then modify the boot menu to also boot windows.

The Short Way
	Install windows on the first partition then linux. During the linux install select grub as the bootloader and write it to the MBR. Find grub.conf in /boot/grub. Add these three lines:
title Windows 2000
rootnoverify (hd0,0)  # both root and rootnoverify work
chainloader +1


The Longer Way
	Install windows on the first partition then linux. During the linux install make a boot floppy and write the bootloader to the linux / partition. Make a dual boot floppy to test the configuration before committing it to the MBR.
mke2fs /dev/fd0
mount /dev/fd0
mkdir /mnt/floppy/boot
mkdir /mnt/floppy/boot/grub
cp stage1 stage2 e2fs_stage1_5 /mnt/floppy/boot/grub
grub
grub> root (fd0)  # tell grub where to find stage*
grub> setup (fd0)  # write floppy boot record from stage*
# this gives error stage1_5 didn't embed, non-fatal
grub> quit
vi /mnt/floppy/boot/grub/grub.conf
default=0
timeout=30
title linux
root (hd0,1)  # linux partition with kernel, /boot in this case (hda2)
# now tell grub kernel filename with path relative to root command above
# also tell grub where the linux / partition is
kernel /vmlinuz-2.4.7-10 ro root=/dev/hda7
initrd /initrd-2.4.7-10.img  # location of initial ramdisk for special drivers
# initrd can be omitted in my install

title windows
rootnoverify (hd0,0)  # location of windows install/boot partition
chainloader +1   # load the windows boot loader from the windows partition
# +1 seems to mean 0+1 or offset 0 and read 1 sector (or maybe read through sector 1).

Comments
	kernel and initrd commands seem to have file system access even though the stage1_5 module failed to embed. I don't know if that means stage1_5 isn't needed for file system access (as opposed to block list access) or if stage1_5 is being picked up from the file each time. I could test this by deleting the stage1_5 file.
	kernel and initrd commands are reading the kernel and initrd files from the hard disk in the location specified by root= in the kernel command. The kernel and initrd commands can follow file links e.g. vmlinuz->vmlinuz-2.4.7-10.
	works fine without the initrd command.
	The windows boot loader is stored in the windows boot partition boot record. In a normal windows boot the boot loader is loaded by the code in the MBR.
	In this procedure the MBR still contains the windows code but that is about to change. If the dual boot floppy works the write grub to the MBR as follows.

Write Grub to the MBR
The stage* files and grub.conf are in /boot/grub as above. /boot is a separate partition.

grub
grub> root (hd0,1)  # location of stage* and grub.conf
# grub seems to look in /grub and /boot/grub for these files
grub> setup (hd0)  # put grub in the MBR (no partition specified)
grub> quit

Edit /boot/grub/grub.conf to look like the grub.conf above.

Make a Boot Floppy containing the Linux Kernel

Take the boot floppy made above (or a copy) and put the kernel and initrd files on it in /boot. Change the root command in grub.conf to read:
root (fd0)  # partition with the kernel
Everything else is the same as above.

Comments
The boot is still to a / directory on the hard disk. To make stand alone linux boot disk would require make the kernel and the / directory much smaller.

--------------76C1E0D4DEB7D17F0529461B--