Subject: Re: Two NetBSDs on one (i386) drive
To: None <firstname.lastname@example.org>
From: David Laight <David.Laight@btinternet.com>
Date: 12/21/2001 21:16:28
> On Wed, Dec 19, 2001 at 10:25:28AM -0500, Rick Byers wrote:
> > If we recognize more than one NetBSD partition on a disk, that means
> > more than one disklabel. Wouldn't that cause a bunch of problems? For
> > example, how do I write the second disklabel when I've booted from the
> > first partition? I would find it confusing because now there are two
> > different NetBSD views of the disk (i.e. the meaning of "wd0a" depends on
> > which partition you booted from - what if you boot from a floppy?)
> Isn't the disklabel inside the NetBSD partition on i386? e.g. at offset
> xyz from the start of the partition, not the start of the disk?
Correct.... which is why you might be able to have more than one...
I've dug a bit deeper today (having got the bootloader code (/boot)
to display the sector number of the start of the partition).
The kernel code that reads the disklabel seems to be hiding in
sys/arch/i386/i386/disksubr.c Who knows where this gets called from!
The lurking problem here is that this code is passed a dev_t number
to identify the drive. This must be the 'whole disk' one (due to the way
the netbsd label is read). Actually there must be a way of getting this
from the dev_t for any partition - otherwise you couldn't read the label
given only the dev_t for the boot partition. Is it always 'd'?
Interestingly (if you believe the comments) this seems to fill in
'e', 'f', 'g' and 'h' for the 'dos' partitions, and thus 'd' (the one
before) for the whole disk. It then overwrites the entire structure
with the one read from the netBSD label sector!
I also notice some 0x1fffffff constants for the size of the disk (if
not known by other means). 29 bits is interesting, max LBA is 28!
(until you try supporting the 160Gb maxtor...)