Subject: Re: disklabel number of partition ?
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: John F. Woods <jfw@jfwhome.funhouse.com>
List: port-i386
Date: 07/01/2000 08:44:34
> >>> I need more than 8 partition on a disk.
> >>> is this is possible ?
> At present, no, not on the i386 port, because MAXPARTITIONS there is 8.
> If you raise MAXPARTITIONS, as sketched on the list, that does it.
> So the answer is "not for a stock system, but yes with some minimal
> code tweaks and a flag day in /dev".

If you raise the bar for the amount of code tweaking you're willing to do,
you can avoid the flag day by changing the  unit/partition split macros
to something like:

#define MOREPARTITIONS 0xC0000
#define	DISKUNIT(dev)	(((minor(dev)&~MOREPARTITIONS) / MAXPARTITIONS)
#define	DISKPART(dev)	(((minor(dev)&~MOREPARTITIONS) % MAXPARTITIONS) | (minor(dev)&MOREPARTITIONS >> 18))
#define	MAKEDISKDEV(maj, unit, part) \
    (makedev((maj), ((unit) * MAXPARTITIONS) + (part & 7) + (part &~7)<<15))

The intent of the code above is to split the partition number into the low
3 bits and the high 2 bits of the minor number, while leaving the existing
unit numbers alone (assuming you have fewer than several hundred disks).
Note that I haven't actually compiled (much less used) the code above, so
you should definitely examine it carefully before trying it.

> > I need this for my 5th msdos partition.
> This sounds as though you're talking about partitions in the MBR, not
> partitions in the (NetBSD) disklabel, in which case the limit is 4, not
> 8, and as far as I know cannot in practice be altered.

I seem to recall that DOS has a hack where the 4th MBR partition can be
given its own MBR table, extending the number of DOS partitions to 7.

It seems unfortunate that NetBSD/i386 shares (to some small degree) DOS's
inability to gracefully handle large disk drives.  (I have a 20GB disk which
has been gathering dust for a month because I haven't had the time to build
a new kernel -- my backup tape drive uses 4GB tapes, you see, so I prefer to
limit partitions to 4GB; and since I also like to have a small root
partition (one without a lot of changing files) and don't need 4GB of swap,
that runs over the budget of 6 useful partitions.)

In fact, while I'm on the topic of large disk partitions, does anyone know
offhand what kind of gotchas are involved with large disks?  As I vaguely
recall, huge cylinder sizes (as may be needed to get a disk to play nicely
with DOS) requires large block sizes due to some limit in the geometry
calculations (but it's been quite a while since I set up any disks, so I
don't remember).