Subject: Re: MBR not working (1.5)
To: Anne Bennett <>
From: Wolfgang Solfrank <>
List: port-i386
Date: 11/21/2001 23:33:02

Anne Bennett wrote:
> This part I don't understand; isn't my disklabel at the start of partition
> a/c already?  Hmm, maybe not, since, after loading the first-stage boot
> from floppy, I was able to speficy "boot sd0a:netbsd", which suggests
> that the MBR was pointing correctly to the NetBSD disklabel -- or does
> it?  How *does* the first-stage boot program find the rest of the NetBSD
> bootcode and the NetBSD partition table when I have pointed it at a
> different device than that from which the first-stage boot was loaded?

Well, since the disklabel is the place that contains the definition of
a/c partition, it's irrelevant, where the disklabel is placed relative
those partitions.  It's only relevant, where it is with respect to the
NetBSD MBR partition, and is contained in the second sector of that
This happens to be the second sector of the disk in your case (since the
NetBSD MBR partition occupies the first 16 sectors of the disk).

If you shift the MBR partition up by 63 sectors, the NetBSD disklabel
have to be shifted, too.

The NetBSD bootcode (as well as the NetBSD kernel) reads the MBR and
a NetBSD MBR partition (partition type 169; or 165, if your
is compiled for backwards compatibility), reads the second sector of
partition and expects the NetBSD disklabel to be within this sector.
This disklabel then defines the NetBSD partitions (a-h or a-p for newer

> But now I really don't get it --  I was initially able to label that disk
> and put data on it even while it had a completely invalid MBR, and playing
> with the MBR (with fdisk) did not appear to damage my NetBSD disklabel.
> How does "disklabel" decide where to put the label?  How does it find
> "the NetBSD part of the disk", especially if the MBR partition table is
> not valid?

Well, I have to guess a bit about the sequence of how you did things.

If NetBSD doesn't find an MBR, or doesn't find a NetBSD partition with a
disklabel, it constructs a fake label.  This fake label will always
partition d: describing the whole disk.

From the data on your disk, it seems as though you had done a
"installboot biosboot.sym /dev/rsd0d" before you did the disklabel
This would have put the NetBSD bootcode with the 16 sector fake MBR
in place.  After that, when you wrote the disklabel, it was placed in
second sector of the disk, as that is the second sector of the NetBSD

ws@TooLs.DE     Wolfgang Solfrank, TooLs GmbH 	+49-228-985800