Subject: i386 booting, take 2
To: None <>
From: Charles M. Hannum <>
List: tech-install
Date: 09/20/1998 17:24:43
I incorporated by suggestion about modifying the boot program.  As you
can see, it simplifies things a bit for many users if we make that

The BIOS and Booting

The NetBSD boot process relies on the BIOS built into your PC.  It
serves two functions: to automatically load the initial part of the
NetBSD boot program, and to act as a backend for the boot program to
read the root file system and load the kernel.

[Begin part that relies on changes to the boot program.]

If you are using the whole boot disk for NetBSD, it's recommended that
you put the root partition at the beginning of the disk.  This will
overwrite the DOS MBR (`master boot record') with the beginning of the
NetBSD boot program.  If you do this, you do not need to worry about
the geometries used by the BIOS, BOS MBR or NetBSD disklabel; you can
use arbitrary values, provided they are large enough to cover the
whole disk.  If you're installing this way, you can skip the rest of
this section.

[End part that relies on changes to the boot program.]

Due to constraints in the BIOS and the DOS MBR, the MBR partition
containing the NetBSD boot program and kernel must lie within the
first 1024 cylinders of the disk.  The easiest way to accomplish this
is to use a geometry that contains 1024 or fewer cylinders.  The
`automatic configuration' for IDE and ATA disks in most BIOSes will
offer a geometry that meets this constraint.  Extension BIOSes for
SCSI disks typically hide this from you but do the right thing.

If your disk is larger than 8GB, or your BIOS does not select a
geometry with 1024 or fewer cylinders, then you will need to make
multiple file systems, and ensure that the root partition is within
the first 1024 cylinders.  [The installation program should notice
this, offer correct default choices, and strongly warn the user if
it's not going to work.]

(Note that these `geometries' are all fake; they do not correspond to
the real media used in the disk drive.  Using completely fictitious
values is not a `bug', and you shouldn't be concerned about this.)

In addition, the disk `geometries' in the BIOS and DOS MBR on the boot
disk must match.  To make this easier, the kernel generates a
prototype (or `default') NetBSD disklabel for a new disk, containing
parameters obtained from the BIOS.  In most cases, this prototype
disklabel is correct and should be used.  This information will be
used when you update the DOS MBR with fdisk(8).

[Begin part that relies on the method I proposed.]

Unfortunately, there is no way for the kernel to directly determine
which hardware devices correspond to the devices the BIOS knows about.
We use the following heuristic, which works on all `off the shelf'
machines with preformatted disks.

* Read the first sector and the geometry from the first 16 BIOS disk
  devices, using the BIOS.

* During autoconfiguration (device detection), when we find a disk,
  read the first sector and look for a BIOS device with an identical
  first sector.  If one is found, use the geometry that the BIOS
  reported for that device.

* If no matching BIOS device was found, query the geometry in whatever
  device-specific fashion is appropriate and use that.

* If more than one matching BIOS device was found, use the geometry
  from the one with the lowest BIOS device number which has not
  already been used.

If you are installing NetBSD on a disk other than the first BIOS
device, and it has not previously been formatted under DOS, then you
will need to determine the `geometry' for this device manually.  For
an IDE/ATA disk, this information is available in the `standard
configuration' section of the BIOS setup program.  For a SCSI disk, it
may be available from the SCSI setup utility, or it may not be
available at all.  [Should we also add a mechanism to query the BIOS
data from the kernel and present this as a list of options in the
installation program?]

[End part that relies on the method I proposed.]