Subject: Re: Boot Sequence, partitions, labels, etc.
To: K. Richard Pixley <K.Richard.Pixley@nominum.com>
From: Ian Zagorskih <ianzag@megasignal.com>
List: port-i386
Date: 07/16/2003 02:25:15
On Tuesday 15 July 2003 17:32, K. Richard Pixley wrote:
> I'm confused about the boot sequence, disk partitions, labels, etc.
> So before I go digging through code I have some questions.  If these
> are answered elsewhere, I'll be happy to follow any pointers offered.
>
> 1) Aside from the "hard partition" type being now obsolete, (ie, we're
>    using NetBSD now rather than 386BSD), is this old post still pretty
>    current?
>
>    http://mail-index.netbsd.org/port-i386/1995/07/20/0002.html

Nice explanation, thanks for the url :) IMO it's still acruall and accura=
te in=20
2003 even was written in 1995.

Let's dig in it. Note that all below is just my own understanding of PC b=
oot=20
process and prior experiments with MBR/FAT/DiskLabel/UFS/FFS and of cours=
e i=20
can be wrong in some moments.

> 2) The above post suggests that the bsd disklabel is ordinarily stored
>    in the NetBSD slice, unless the disk is completely devoted to
>    NetBSD, in which case it's at the beginning of the disk.  I
>    couldn't find any other statements about this in any of the other
>    doc.

This doc dosn't suggest to put disklabel into MBR. If you devote the whol=
e=20
disk to NetBSD or to set of systems which understand disklabel IMO it is =
much=20
better to get rid of ancient MBR and use only disklabel so this would loo=
k=20
like:

CHS 0:0:1, 1 sector - primary boot loader which understand disklabel.
CHS 0:0:2, sectors for disklabel which actually "partitions" the disk (I =
don't=20
remember if disklabel must reside exactly in sector 0:0:2 not but that do=
sn't=20
so matter and depends on primary boot loader).

That's related to "suggests". This is just two alternarive ways - you use=
 MBR=20
or you don't. For disklabel care OS[es] you can freely not to use MBR. Fo=
r=20
ignorant (windoze, dos, os2 etc) you still *have* to use MBR and put=20
disklabel into separate MBR's defined partition.

>    Where is the bsd disklabel stored? Is it at the beginning of the
>    disk?  At the beginning of the NetBSD "slice" in the MBR/dos
>    partition table?  Somewhere else?

If you use MBR you have for example the following tree:

-------
CHS 0:0:1:
=09primary boot loader code which loads MBR below
=09MBR:
=09=09partition0: type=3Dsomething start=3Dxxx size=3Dxxx active=3Dno
=09=09partition1: type=3D169 (NetBSD) start=3Dyyy(LBA) size=3Dyyy active=3D=
yes
=09=09partition2: type=3D0 (unised)
=09=09partition3: type=3D0 (unised)

LBA yyy:
=09secondary boot loader which loads disklabel, size=3Dx sectors
LBA yyy+x:
        disklabel:
=09=09partition 0 (a) type=3DBSD 4.2
=09=09partition 1 (b) type=3Dtralala
=09=09partition 2 (c) type=3Dtralala
=09=09.....
=09=09partition x (..) type=3D0 (unused)
-------

=2E.so disklabel with all it's sub-partitions are "wrapped" into MBR part=
ition.

If you do not use MBR things looks simplier:

-------
CHS 0:0:1:
=09primary boot loader which loads disklabel, size=3Dx sectors
LBA x:
        disklabel:
=09=09partition 0 (a) type=3DBSD 4.2
=09=09partition 1 (b) type=3Dtralala
=09=09partition 2 (c) type=3Dtralala
=09=09.....
=09=09partition x (..) type=3D0 (unused)
-------

> 3) All the netbsd doc I could find, as well as the above post, refer
>    to "the netbsd" slice or hard partition.  I'm guessing that they
>    really mean, "the first netbsd" slice in the MBR.  Am I guessing
>    correctly?

I'm not sure if exactly boot code does understand several disklabels wrap=
ped=20
into MBR. Of course to be sure that's enough to look into the code.

> 4) It appears as though that assumption, "the first netbsd" slice,
>    implies that while there's room for a second bsd disklabel on a
>    second netbsd slice, it could never be read.  Is this correct?

Technically, you can create up to four disklabels into one MBR so there c=
an be=20
several disklabels on one hard disk. Even more if you put disklabels into=
=20
extended partitions.

Last time i checked mbrlabel code (i386/1.6.1) i found that it cares abou=
t=20
disklabels inside extended partitions. So in general you may have more th=
en=20
one disklabel on hdd with one "primary" inside master MBR partition and=20
several "slave" inside one or more extended partitions.

--=20
JSC Novosibirsk Geophysical Equipment Development Center.
WEB=09http://www.megasignal.com