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.
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=1You 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:
copy /b stage1_bare stage2 grub.raw
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.
To find out where the "stage2" is using GRUB itself:
dd if=stage1_new of=/dev/fd0 bs=1 count=3 dd if=stage1_new of=/dev/fd0 bs=1 seek=62 skip=62 count=450NOTE: This is to be compatible with a FAT BIOS Parameter Block. If the partition the "stage1" is being installed in doesn't use one, then feel free to use something like the "stage1" "dd" command listed in method #1 above.
NOTE: Similar to #2 above, by altering the embedded data, this technique can be used for manually installing on any partition of a hard disk (the stage1 can be either in the MBR or in the first block of a partition... IMPORTANT!! if it is in the MBR, the "count=450" in the second "dd" command should be changed to "count=384").
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:
install= /boot/grub/stage2...sets up a blocklist to load stage2 directly. Similarly, a stage1.5 can be set up to load via:
install= /boot/grub/stage1.5...which sets up a blocklist to load stage1.5, which will then look for the stage2 in /boot/grub using the filesystem code normally (this might be desirable if the stage2 will be changed often). It is important to note that the appropriate filesystem code should be compiled into the stage1.5, as the one provided with the GRUB distribution can only be used for BSD FFS, though it's only a makefile change.
install= hd(0,1)/boot/grub/stage2...which sets up a blocklist to load stage2 from the second partition of the first hard disk directly (presuming that's the "install partition), but saves the bootable block as the first sector of the floppy! This is useful for the case of not wanting GRUB to overwrite the hard disk boot sector itself. Since GRUB is still operating, it can still be used to finish booting an OS off of the hard disk or another floppy (though it's stage1 has been messed up... or you can use insert another floppy with an appropriate GRUB stage1 as the first sector, and it will perform the operation there).
root= hd(0) install= hd(0,1)/boot/grub/stage2...this sets the root partition to encompass the whole disk, then reads the file from the second partition of the first hard disk (presuming that is the install partition), gets the stage1 from the MBR area, places the appropriate blocklist, then writes it back.
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.