A replacement master boot record
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Contents
~~~~~~~~
1. Copyright
2. Introduction
3. Basic Installation
4. The boot process
5. Configuration
6. Acknowledgements

1. Copyright
~~~~~~~~~~~~

Copyright (C) 1995, 1999 Neil Turton

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

See file COPYING for details

2. Introduction
~~~~~~~~~~~~~~~

When a PC is reset, it goes through a series of self tests, and then
attempts to load an operating system.  The loading process requires a
number of steps.  When booting from a hard disk, these are to read and
execute the first sector of the first hard disk, called the master
boot record, which in turn, reads and executes the first sector of one
of the partitions on that disk, called a boot sector.  The program
code on this sector then loads the operating system.  The standard MBR
(master boot record) which comes with MSDOS is fairly simple, and
limited in a number of ways.  The MSDOS MBR is also non-free which
means that it cannot form part of a completely free system.  This MBR
is more complicated, and aims to overcome these limitations.

3. Basic Installation
~~~~~~~~~~~~~~~~~~~~~

See the file 'INSTALL' for generic building instructions.  By default
this package installs the program install-mbr in /usr/local/sbin.
This program is used to install the MBR and contains a copy of the
MBR within itself.

Before you begin, make sure you have an alternative way of booting
your computer (ie. boot floppy).  When all fails and your computer
sits there asking you to insert a system disk, you'll be stuck if you
don't have one.

Installation is done using the program called install-mbr.  If this
program is not on your path, you will have to invoke it as
<dir>/install-mbr (./install-mbr if it is in the current directory).
It is recomended that you test the master boot record with your system
before you install it on the first sector of your hard disk.  You may
wish to skip this step if you took my earlier advice and made a boot
floppy.  To do this, put a blank floppy disk in your first disk drive,
and type the command:
  install-mbr /dev/fd0 -T /dev/hda

If your primary disk is a SCSI disk, you will have to replace hda in
the command above with sda.  This command tells install-mbr to install
it's built-in copy of the master boot record on the first floppy drive
(/dev/fd0), taking the partition table from the first IDE hard disk
(/dev/hda).  Booting from the floppy disk should load your operating
system as usual.

Once the master boot record has been tested, you can install it on
your hard disk using the following command:
  install-mbr /dev/hda

4. The boot process
~~~~~~~~~~~~~~~~~~~

When the MBR is first loaded it waits for a configurable length of
time (1 second by default), monitoring the keyboard, for key presses.
If the MBR detects a key press, it will interrupt the boot process,
and display it's prompt.  Otherwise, it will load the first sector of
the default partition, and execute it.  If a disk error occours, the
MBR will display it's prompt.

4.1 The boot prompt
~~~~~~~~~~~~~~~~~~~

The boot prompt looks something like this:

14FA:

This is the list of valid keys which may be pressed.  This means that
partitions 1, and 4 can be booted, also the first floppy drive
(F).  The A means that 'advanced' mode may be entered, in which any
partition may be booted.  The prompt for this mode looks like this:

1234F:

The only other valid key which may be pressed is RETURN, which
continues booting with the default partition.

5. Configuration
~~~~~~~~~~~~~~~~

The master boot record may be configured using command line options to
the install-mbr program.

5.1 Basic usage
~~~~~~~~~~~~~~~

The install-mbr program is invoked as follows:
  install-mbr <target> [options]

The target parameter specifies the path of the device (of file) to
install the master boot record on.

5.2 Installation options
~~~~~~~~~~~~~~~~~~~~~~~~

These options change the way the installation program operates.

-f                                Override some sanity checks.

This option currently overrides a check to make sure the specified
target is valid.

-I <path>                         Install code from the specified file.

This option may be used to install code other than that which is built
in to install-mbr.  It is mainly useful for testing.

-k, --keep                        Keep the current code in the MBR.

This option may be used to modify the parameters stored in the MBR
without updating the code.

-l, --list                        Just list the parameters.

This option may be used to view the parameters stored in the MBR.  It
implies the -n flag unless an option other than -o, -v or -l is given.

-n, --no-act                      Don't install anything.

This option ensures that the target is not modified, as it is opened
in read-only mode.

-o <offset>, --offset <offset>    Install the MBR at byte offset <offset>

This option may be used to install the MBR somewhere other than the
start of the target.  The offset specifies the number of bytes from
the start of the target at which the MBR should be installed.

-P <path>, --parameters <path>    Get parameters from <path>.

This option may be used to copy parameters from somewhere other than
the target.  The path specifies a location where a version of this MBR
has been installed.  It could be used to copy parameters from one disk
to another disk.

-r, --reset                       Reset the parameters to the default state.

This option is used to reset the boot parameters to the state found in
the installed code (or code which would be installed if -k were not
specified).

-T <path>, --table <path>         Get partition table from <path>.

The master boot record currently uses the partition table in the
sector which contains it to locate boot sectors (This behaviour may
change with future versions of the MBR, in which case the option may
be withdrawn).  The -T option is used to copy a partition table from
another location to the target location.  Any data stored on the
target disk may be lost (as the partition table is overwritten), so
this option should be used with extreme caution.  As the partition
table is copied, any changes made to the partition table will not be
noticed.  This option is only provided to make floppy testing easy.

-v, --verbose                     Operate verbosely.

When invoked with this option, install-mbr will display some
information about what it is doing.

-V, --version                     Show version.

This option will cause install-mbr to display it's version number and
exit.

-h, --help                        Display help message.

This option will cause install-mbr to display a help message and exit.

5.3 Parameter options
~~~~~~~~~~~~~~~~~~~~~

-d <drive>, --drive <drive>       Set BIOS drive number.

This option is used to allow the MBR to boot a drive other than the
first hard disk.  It may be specified in decimal or hexadecimal
if prefixed with 0x.

-e <option>, --enable <option>    Select enabled boot option.

This option sets the list of boot sectors which may be loaded (or
advanced mode).  Use -e +<spec> to add a sector to the list or -e
-<spec> to remove a sector from the list.  Use -e =<spec> to set the
list to <spec>.  Values of <spec> are:

  1,2,3,4  The specified partition number.
  F        The first floppy disk.
  A        Advanced mode (not a boot sector).

-i <mode>, --interrupt <keys>     Set interrupt mode. (a/c/s/cs/n)

This option sets the list of events which will cause the MBR to
display it's prompt.  Use -i +<event> to add an event to the list or
-i -<event> to remove an event from the list.  Values of <event> are:

  s   A shift or control key is pressed.
  k   A non shift-like key is pressed
  a   The prompt is always displayed.
  n   Never display the prompt (unless an error occurs).

-p <partn>, --partition <partn>   Set boot partition (0=whole disk).

This specifies the default boot sector to load.  Valid values of
<partn> are:

  1,2,3,4  The specified partition number.
  F        The first floppy disk.
  D        The partition marked with the bootable flag in the
               partition table.

-t <timeout>, --timeout <timeout> Set the timeout in 1/18 second.

This option changes the time which the MBR waits for before booting
the default partition.

5.4 Examples
~~~~~~~~~~~~

install-mbr -kr /dev/hda

Reset the parameters on /dev/hda without installing any new code.

install-mbr -I my-mbr -T /dev/hda -P my-parameters /dev/fd0

Install to /dev/fd0, taking code from my-mbr, partition table from
/dev/hda and parameters from my-parameters.

install-mbr -l -o 128 hdimage

List the parameters stored at offset 128 in hdimage (may be a DOSEMU
image).

install-mbr -d 0x81 -T /dev/hdb /dev/fd0

Install on /dev/fd0 to boot from BIOS drive 129 (0x81) with partition
table copied from /dev/hdb.

install-mbr -e 13 /dev/hda
install-mbr -e 2 -e =13 /dev/hda
install-mbr -e1 -e3 /dev/hda

Enable booting from partitions 1 and 3 on /dev/hda.  Other locations
are disabled.

install-mbr -e +f-a -i sk /dev/hda

Enabled booting from the floppy drive, and disable advanced mode.
Display the prompt if any shift, control or non shift-like key is
pressed.  Other settings are untouched.

6. Acknowledgements
~~~~~~~~~~~~~~~~~~~
Thanks to:

  Santiago Vila <sanvila@unex.es> for maintaining the Debian package.

  Kalle Olavi Niemitalo <tosi@ees2.oulu.fi> for submitting a number
    of bug fixes.
