Re: how to make a boot disk (part I)
> > $ mkdir /floppy/boot/grub
> > $ cp /usr/share/grub/i386-pc/stage1 /floppy/boot/grub
> > $ cp /usr/share/grub/i386-pc/stage2 /floppy/boot/grub
> > dd if=/usr/share/grub/i386-pc/stage1 of=/dev/fd0 bs=512 count=1
> > dd if=/usr/share/grub/i386-pc/stage2 of=/dev/fd0 bs=512 seek=1
> What is the point of installing the same data in two places on the
> boot floppy? (once in the filesystem and once in the first few
The first few sectors make the floppy bootable. Having them in the
filesystem as well makes it easier to find them when you want to copy them
onto another disk with GRUB's install command.
The stage1 needs to appear in the floppy's first disk block (sector) to
make the floppy bootable. Rather than also putting it in the filesystem,
you can copy it directly from the first block with GRUB, by using
`(fd0)+1' in place of `(fd0)/boot/grub/stage1'.
Conversely, the stage2 can go anywhere on the floppy, as long as the list
of blocks is written into the boot block (stage1 copy). The stage1 image
as built assumes that stage2 will be found in contiguous blocks starting
with the second block on the disk (right after the boot block containing
stage1). This makes it easy to create an initial GRUB floppy with the two
dd commands above.
When you use GRUB's `install' command to copy stage1 into a disk's boot
block, it modifies the image on the way to change the block list saying
where to find stage2. Thus it is conventional to stick stage2 in the
filesystem (usually in /boot/grub/stage2, but the directory and file name
used don't actually matter to GRUB).
> This is a different disk. I couldn't figure out how to install GRUB on the
> boot image directly, so I had to make a GRUB boot disk, and then install
> Grub on the other disk by booting the GRUB boot disk first.
> If you have a command to install GRUB directly from the Unix environment,
> let me know.
With GNU GRUB (as in cvs anyway, I haven't noticed if there have been
releases), there is a `/sbin/grub' program built that does just this.
(Gord and Okuji put it in there just for you!) It gives you the GRUB
menu/command line environment in a Unix program, and accesses the disks
using /dev devices. Note that it does all filesystem access directly (just
like the real GRUB will) through the disk devices, so you must sync and
should unmount or remount read-only on Linux the disks you will access with
/sbin/grub (even the ones you are only reading and not writing).
Normally it uses curses to give the same screen interface you get at boot time.
It also has a batch mode intended for using it from scripts.
baalperazim 132 % grub --help
Usage: grub [OPTION]...
Enter the GRand Unified Bootloader command shell.
--batch turn on batch mode for non-interactive use
--boot-drive=DRIVE specify stage2 boot_drive [default=0x0]
--config-file=FILE specify stage2 config_file [default=/boot/grub/menu.lst]
--help display this message and exit
--hold wait until a debugger will attach
--install-partition=PAR specify stage2 install_partition [default=0x20000]
--no-config-file do not use the config file
--no-curses do not use curses
--read-only do not write anything to devices
--verbose print verbose messages
--version print version information and exit
Report bugs to firstname.lastname@example.org