GRUB Installation Guide

by Erich Boleyn


Contents

Methods #'s 1-3 are basically manual installation methods. Method #4 automates the most tedious steps, also making it much easier (though method #4 requires a "raw" GRUB floppy made via method #1).

Getting Started Quickly

If you just want to use GRUB, or simply try it out quickly, try option #1 in the following section to create a "raw" GRUB floppy.


NOTES on Manual Hard Disk Installation

Most of these notes are only relevant if doing one of the manual installation methods, as method #4 will take care of most of this for you.

This is very similar to installing on a floppy, but an important thing to note here is the partitioning of the hard drive (logically on the hard disk, a partition is treated much like a big floppy).

For Hard Disks with a large area before the partitioned space: If your hard disk has a large area before the unpartitioned space (and is large enough for the stage1.5 or stage2 as desired, which it usually will be), then an install technique of placing all the components before the first partition of the disk (but otherwise like method #1 or #2) can be used. See the notes on the hard disk MBR and such below.

For installing in a BSD partition, place the "ffs_stage1_5" starting at sector 2 of the partition (and make sure it's a MAXIMUM of 14 sectors long!!! ...else it will write over part of the superblock! Don't worry about the one included in the default distribution, it meets this criteria easily enough).

The stage1 can be placed as sector 0 of an BSD partition safely. BE SURE TO REMEMBER THAT THE EMBEDDED PARAMETERS IN STAGE1 NEED TO BE CHANGED BEFORE DOING THIS, if using a manual install!!!

VERY IMPORTANT NOTE!! : If a "stage1" on a hard disk is going to be used as the first sector of the hard drive, i.e. as an MBR, then the count for the second command for #3 above should be changed from 450 to 384, else the partition table will be deleted. This should be done for extended partitions as well.

RELATED IMPORTANT NOTE!! : The code for probing a floppy is in the area used for a partition table on a hard disk, so a stage1 used on a GRUB floppy can be used for installing a hard disk, but not the other way around.


#1 : Manual Install on "raw" disk

This installation method can generally only access the command-line part of the interface (since there is no filesystem in which to find a config-file). It is also by far the simplest installation method to get going.

Execute your OS's equivalent of (this should work for recent FreeBSD versions and Linux just fine):

	dd if=stage1/stage1_bare of=/dev/fd0 bs=512 count=1
	dd if=stage2/stage2 of=/dev/fd0 bs=512 seek=1
You can also use "make bare" in the "stage1" directory, and "make floppy" in the "stage2" directory, which will perform the above commands.

Under Windows NT (and maybe Windows 95), courtesy of Eric Hanchrow (erich@microsoft.com), for floppies only:

NOTE: This will generally destroy anything currently on this floppy.


#2 : Manual Installation on BSD FFS Floppy

This installation method can access all parts of the interface if a config file is placed in the "/boot/grub" directory called "menu.lst".

Go to the "stage1" directory, type "make ffs" (this should work for recent FreeBSD versions and Linux just fine, otherwise look at the makefile and figure out your OS's equivalent). Then go to the "ffs_stage1_5" directory and again type "make floppy". Finally, make a "/boot/grub" directory on the floppy, and copy the "stage2" file from the "stage2" directory into it.

NOTE: A similar technique can be used for hard disk partitions if the appropriate elements in the embedded data of stage1 is changed to account for it.


#3 : Manual Install on Floppy with any Supported Filesystem

Copy the file "stage2" from the directory "stage2" onto the floppy somewhere.

To find out where the "stage2" is using GRUB itself:


#4 : Partially Automated Install on Floppy or Hard Disk

This method uses some of GRUB's debug code to automate parts of the install process. Given that all commands can be used in config-file entries, this could very likely be used as part of a completely automated set of install scripts.

NOTE: The one thing this doesn't set is the "install partition" in the embedded data for the stage1.5 or stage2 which is loaded. This needs to be set manually (or by your install script).

First, you make a "raw" GRUB floppy created via install method #1 above.

On the partition that is the desired area for GRUB to be installed in (call it the "install partition"), make a "/boot/grub" directory and place the stage2 and menu.lst (config file) there. (If desired, place the stage1.5 there as well)

Use the "install=" command to create a stage1 with the appropriate blocklists in it (see the list of commands for a basic description, NOTING that it depends on the last character being a "5" if to determine if it should use the default starting address for the stage1.5, which can be simulated by simply having a space then a "5" after the filename... no trailing spaces are allowed for detection of the "5").

Some examples are:

IMPORTANT NOTE! GRUB cannot currently directly install a stage1 blocklist in any sector other than sector 0 of a disk (for a floppy this is normal, but on a hard disk, this would only be the MBR). The first method listed for creating the hard disk stage1 is appropriate to use here, since it doesn't actually write the stage1 to the hard disk.

An easily imaginable way of performing this as part of an automated installation process would be to note that the commands listed above can be part of any sequence of commands in an entry in a GRUB config file, so this could be automated even more by using a GRUB floppy with a filesystem and config file, with an entry such as:

	# Start of entries
	title=	   Linux HD install

	# install commands
	root=      hd(0)
	install=   hd(0,1)/boot/grub/stage2

	# actually boot here
	root=      hd(0,1)
	kernel=    /zImage root=/dev/hda2
...then have the install script continue from there after boot of the OS.


erich@uruk.org