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

Anne Bennett wrote:
> | NetBSD disklabel disk geometry:
> | cylinders: 6576 heads: 8 sectors/track: 168 (1344 sectors/cylinder)
> |
> | BIOS disk geometry:
> | cylinders: 553 heads: 255 sectors/track: 63 (16065 sectors/cylinder)
> |
> | Partition table:
> | 0: <UNUSED>
> | 1: <UNUSED>
> | 2: <UNUSED>
> | 3: sysid 169 (NetBSD)
> |     start 0, size 16 (0 MB), flag 0x80
> |         beg: cylinder    0, head   0, sector  1
> |         end: cylinder    0, head   0, sector 16

Here the NetBSD partition of the disk starts at the very first sector of
the disk.
This is perfectly OK, as long as you do it consistently (I'll come back
to this
in a minute).

To address Christoph's concern about the size of the partition, the
small size
of the partition is on purpose.  Neither the MBR bootcode nor the NetBSD
or the NetBSD kernel look at the size of an MBR partition.  They all are
interested in the start of the partition.

There are some PCs out there, where the BIOS tries to deduce the disk
geometry by
matching the start/size numbers with the beg/end cylinder/head/sector
Those may get confused if these numbers cannot be matched.  By
specifying values for
this partition which works for any disk, independent from its actual
geometry, we
try to make those BIOSs happy.

> In case it matters, the disk label partitions are:
> #        size   offset     fstype   [fsize bsize   cpg]
>   a:    64512       63     4.2BSD     1024  8192    16   # (Cyl.  0*- 48*)
>   b:  1038177    64575       swap                        # (Cyl.  48*- 820*)
>   c:  8887137       63     unused        0     0         # (Cyl.  0*- 6612*)
>   d:  8887200        0     unused        0     0         # (Cyl.  0 - 6612*)
>   e:   408576  1102752     4.2BSD     1024  8192    16   # (Cyl.  820*- 1124*)
>   f:  6558720  1511328     4.2BSD     1024  8192    16   # (Cyl. 1124*- 6004*)
>   g:   817152  8070048     4.2BSD     1024  8192    16   # (Cyl. 6004*- 6612*)

Here your a: and c: partitions starts at offset 63.  In order to
understand the
problem, you have to understand what's going on during bootup:

After initializing the system, the BIOS reads the first sector of the
disk and
(after a simple verification that it's not empty) jumps to the just read
For harddisks, this is normally the MBR, which contains the fdisk
table plus some master bootcode.  This master bootcode searches through
fdisk partition table for an active partition, reads in the first sector
this partition and itself jumps to the newly read code.  If this is a
partition, this hopefully contains the first sector of the NetBSD
which will read in the rest of the NetBSD bootcode, including the NetBSD
partition table (which happens to be in the second sector of the
and then boot the kernel.

Keeping in mind that the MBR partition table on your disk has just one
partition which starts at the very beginning of the disk, you probably
imagine now what happens during the boot of this disk: it simply keeps
the MBR over and over again!

There are two possible solutions: either make your MBR partition start
offset 63, or make your NetBSD a: anc c: partitions start at offset 0. 
In the
latter case, you effectively eliminate the MBR (albeit it still has a
(fake) MBR
partition table), and the BIOS itself instead of the MBR code will read
the first sector of the NetBSD bootcode directly.

Things to be aware of:

When shifting the MBR partition to start at offset 63 (remember that its
size is
irrelevant, as long as you either don't have one of the above mentioned
or you enter consistent data in order to not confuse it, and as long as
you are
not sharing the disk with other OSs), you'll also shift the NetBSD
partition table.
Therefore you'll have to re-disklabel the partition after doing the
fdisk thing
with the same data it has now.

If you instead go the other route of changing the start of the a: and c:
you want to backup the a: partition _before_ changing it, disklabel sd0
to change
the start and size of the partitions (keeping the other partitions the
newfs sd0a and restore the backed up data.  Don't forget to installboot
after this.

Hope it helps.

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