INSTALLBOOT(8)

NAME
installboot - make a device bootable

SYNOPSIS
installboot -i(mage) image [label:]kernel mm fs ... init
installboot -d(evice) device bootblock boot
installboot -b(oot) device bootblock boot [label:]image ...
installboot -m(aster) [fix] device masterboot

DESCRIPTION
Installboot may be used to make a device bootable by constructing a kernel image and installing bootstrap code into the boot block of a Minix filesystem. To understand how this can be done one first has to know what happens when a PC is booted.

When the power is turned on the typical PC will try to read the first sector from the first floppy disk or from the first hard disk into memory and execute it. The code obtained from the hard disk (from the so-called master boot sector) will immediately replace itself by the code found in the first sector of the active partition. Thus the PC is now executing the bootstrap code found in the first sector of /dev/fd0, /dev/hd1, /dev/hd2, /dev/hd3, or /dev/hd4. The bootstrap will locate the operating system on the device it itself was loaded from, load it, and execute it, usually in a two phase process.

To make a Minix filesystem /dev/fd0 mounted on /mnt bootable, enter the following:
    cp boot /mnt/boot installboot -image /mnt/minix kernel mm fs init installboot -device /dev/fd0 bootblock boot

The "boot" program in the example is named the "boot monitor". It is loaded by the bootblock code placed in the boot sector of /dev/fd0 and it will take care of loading the kernel image "minix" from the root directory of the filesystem. See monitor(8) for a description of the boot monitor.

The most important aspect of this now bootable device is that it is not bound to type of media it is on, as the bootblock is the same for double and high density 3.5 and 5.25 inch floppy disks and the hard disk. You can copy it raw to /dev/hd3 for instance, put an active flag on partition 3 (see fdisk(8)) and boot it. I routinely make raw copies of my hard disk root file system to floppies and these floppies are again bootable without change. Combined with a stripped /usr file system on floppy, I can always get my system back to life in case of disaster.

OPTIONS

-image
    The -image option (or any prefix down to -i) combines the executable files needed to run Minix in one file. Only the names and a few zero bytes are inserted into the image. The name is for identification and the zeros are used to pad separate pieces to sector boundaries for fast loading. Each executable is normally stripped of its symbol table, unless a -s flag is placed before it. An executable may be prefixed with a label. The monitor may be instructed to not load processes with the wrong label. So more than one kernel process may be included in the image, each with a different winchester driver for instance.

-device
    Installs bootblock in the boot sector of device together with the disk addresses to boot. These disk addresses are needed to load boot from the file system at boot time. If the boot parameters sector (the second half of the boot block) is found to contain garbage, it is cleared to null commands. Again see monitor(8). The device need not be mounted when installboot is run, nor does it matter if it is. Installboot needs to be run again if boot is rewritten, because it will then occupy a new place on the disk.

-boot
    This option fills a blank floppy in device with boot code and kernel images. This "boot disk" does not have a root file system, only the boot monitor and Minix kernels. The boot parameters sector is filled with code that enables menu options for selecting an image. After loading an image, the monitor will ask you to insert a root file system diskette before starting Minix. The labels used on the images should ideally match those on the executables used inside the image. You can put a comma separated list of labels on an image for each label used within the image. If a label-list is omitted on an image, then that image will be selected by default.

-demo
    This is a special feature for creating a demo disk. It works just like the -boot option, except that the device must contain a file system. Use it to dress up a small root file system with boot code and a kernel to make a single floppy Minix demo. The file system must be small enough to allow for the monitor and images be placed *after* it.

-master
    This option installs the masterboot program into the boot sector of the given device. If another device is given instead of masterboot then its bootstrap code is copied to device. The master bootstrap on a hard disk boots the active partition on that disk at boot time. The MS-DOS fdisk command normally puts a master bootstrap on the hard disk, but the masterboot program in this package has a lot more features:
    If the ALT key is held down while booting then '/dev/hd?' appears and you are expected to type a number key (0 - 9) to select the device to boot. If a fix key is given (0 - 9) then the bootstrap is locked into booting the given /dev/hd device. This is needed if 'boot *hdN' is used from the monitor to boot an O.S. that needs the active flag set. If installed on a floppy then it will try to boot the next floppy or the first hard disk. Ideal for floppies with just data on it, they will no longer obstruct the boot process if left in the drive. Also a very useful trick to boot from floppy drive 1. If installed on a hard disk then the active partition is selected and booted as usual, unless none of the partitions is marked active, then it will boot the next disk. The latter is useful if you want to boot an operating system from the second disk by default.

A backup copy of the current master bootstrap can be made with:
    dd if=device of=backup-file bs=446 count=1
A simple 'cat backup-file > device' will put it back.

SEE ALSO
fdisk(8), monitor(8).

DIAGNOSTICS
Lot's of numbers describing executables being read, addresses patched.

Errors about missing files, nonexecutable files, etc.

A very useful warning if a segment of an i8086 executable is larger than 64K.

A warning and a ten second countdown if -boot is about to scribble over a file system.

BUGS
It has four more options than the SunOS installboot program it is modeled after.

The symbol table support is a misfeature, only a debugger can use it. Time spent fiddling with debuggers is better used finding bugs.

The bootblock code has been crunched to such ugliness that you can use it scare little kids out of your garden.

AUTHOR
Kees J. Bot (kjb@cs.vu.nl)