Subject: Re: Centris 610
To: port-mac68k <port-mac68k@NetBSD.ORG>
From: Bob Nestor <rnestor@metronet.com>
List: port-mac68k
Date: 11/07/1996 18:07:44
Jesse wrote:

>Whoa!  Wait a minute, are you sure?  I'm quite certain that I remember
>a "partition type" option (which could be AUX Root, AUX Root&Usr, AUX
>Swap Slice 1, etc...  Radio buttons, though, with certain fixed
>choices) and a "partition name" option, which was an edittable text
>field.  In fact, I'm quite sure I changed the "name" to be something
>funky (Like NetBSD or something).  Sorry to be so vague and unclear; I
>don't have access to MacOS right now.  But I remember this quite
>clearly from the many times I have repartioned various hard drives...

Yes, I'm pretty sure.  A few weeks ago I posted the following description 
hoping to provoke a discussion while I was making the recent changes to 
"mkfs":

The disk partitioning process is really nothing more than dividing up the 
disk into segments and building the Partition Map which describes these 
segments.  Apple has defined the layout of the Partition Map which 
includes things such as the starting block number, block count, partition 
type and option partition name among other things.  The Partition Types 
are defined by Apple and most disk formatters follow the Apple 
definitions, but some don't. All MacOS partitions are of the "Apple_HFS" 
type, and all AU/X (and NetBSD) partitions are of the "Apple_UNIX_SVR2" 
type. It's the job of "mkfs" or "newfs" under NetBSD to lay out the 
blocks in the partition before it can be used for files just as the 
"Initialize" command does to MacOS partitions.

The "mkfs" application finds it's partitions by scanning the Partition 
Map for all "Apple_UNIX_SVR2" type partitions.  The Installer and NetBSD 
refine this by looking at the optional partition name field. If the 
partition is an "Apple_UNIX_SVR2" type with "swap" any place in the name, 
it's designated as a SWAP Partition under NetBSD. If the type is 
"Apple_UNIX_SVR2" and the name field contans the string "root", it's 
designated as a Root or a Usr Partition.  The boot partition (passed by 
the Booter?) is assigned slot "a", any additional partitions with "root" 
in the name are assigned to slots "g", "e", "f", and "h" in that order. 
(The Installer only assigns partitions thru "g" - it appears to have an 
"off-by-one" error.) Slot "c" is always set up to cover the entire disk, 
and this is probably historical more than anything else. Slot "d" and any 
unfilled "e", "f", "g", or "h" slots are filled with information mapping 
to the non-"Apple_UNIX_SVR2" type partitions starting with the first 
partition above the Partition Map which is usually the Driver Partition. 
That's why slot "d" almost always shows up mapped to the "Apple_Driver" 
or "Apple_Driver43" Partition.

Since all the "magic" is driven off what is contained in the Partition 
Map, some of us have wondered if it wouldn't be possible to just re-write 
parts of the Partition Map. That way a user could use any disk 
formatter/disk partitioning software and define whatever partitions he 
(or she) desires. Make them all Apple_HFS partitions if that's what your 
formatter supports. Then teach "mkfs" to re-write the Partition Map 
blocks so the user can convert any disk Partition to a type required by 
NetBSD. With this approach we don't have to worry about AU/X or NetBSD 
partition support in the formatter.  Also we then have something to build 
on for the IDE disks which we'll probably want to support sometime to 
bring system like the Quadra 630 on-line.
 

I wrote this based on the research I'd done to that point which included 
reviewing past posts on the partitioning process, scanning the code in 
the Kernel, Mkfs and the Installer.  I also did (what I thought) was 
extensive testing with an Apple 160Meg HD and the disk formatters I have 
on hand (Apple HD Setup, Apple AU/X HD Setup, Transoft, APS, Aunibus, 
RealTech and Super Spot).  Using a debug version of "mkfs" I dumped the 
resulting Disk Partition Maps and tested mounting them with the Installer 
and with a GENERIC 1.2 Kernel.  The thing to remember is that not all 
disk formatters are alike in the options they provide to the user, so I 
thought it was important to come up with a workable explaination that 
worked with as many disk formatters as users might encounter.  Certainly 
what I wrote is not the only way things can be done, but does represent a 
workable solution that should be applicable to almost all disk formatters 
a user might encounter while trying to come up to speed on NetBSD/mac68k.


As for the changes in the current version of "Mkfs" that might be of 
interest here:
	  
   Code has been added to allow any Partition, other than the Partition 
Map and
   Driver Partition(s), to be converted into NetBSD Root & Usr Partitions,
	  NetBSD Swap Partitions, MacOS HFS Partitions, or into Apple_Free 
Partitions.
	  This should make it possible to use any Disk Formatter to prepare a 
NetBSD
	  volume, even if that Formatter does not support creation of AU/X 
partitions.
	  An Apple_Free Partition is one that is allocated but not in use. It 
won't
	  show up under MacOS so it's a good way of reserving disk space for 
future
	  allocation and use.
	  
   Selecting any type of BSD partition (AU/X, NetBSD, Root or Swap) for 
change
   and doing the change without modifying the Partition Type will cause 
the
	  Partition Name to be re-written as a NetBSD Partition Name.  No 
changes are
	  made to Apple_HFS Partitions unless the user specified a Partition Type
	  other than Apple_HFS.

   There is no check for an improper use of an active MacOS HFS partition
   when converting to a NetBSD type.  The user is warned about converting
	  any HFS partition that is mounted, but failure to heed the warning can
	  lead to possible disk corruption, system crashes or worse.
	  
   Some disks and/or partitions may not format correctly and the program 
may
   hang.  This may be related to having a block count not evenly divisable
	  by the block-per-cylinder value.  For some reason running with the 
debug
	  statements enabled seems to get around this and allow formatting of the
	  partition.
	  
   An attempt is made to pull up the MacOS Disk Partition Name from the 
info
   recorded in the partition itself.  The Partition Map Block associated 
with
	  the Disk Partition does not always contain the MacOS Partition Name.  
This
	  is an optional field entry in the Map Block and not all Formatters 
take the
	  time to initialize it.  Also, the Disk Partition Name for a MacOS 
Partition
	  can be changed under MacOS and this is not reflected in an updated Map 
Block.
	  
   Some disk formatters complain if they don't recognize the "standard" 
Partition
   Names that they use when initializing the disk.  This shouldn't be 
much of a
	  problem, but it's anoying (and frightening) when one uses their disk 
formatter
	  to re-partition a disk that's been touched by this version of Mkfs.
	  
   NetBSD can be pretty anti-social when faced with disk partitions it 
thinks it
   should be able to mount and use when they aren't properly formatted. 
Therefore
	  it's pretty good practice to not create a NetBSD Root & Usr Partition 
without
	  running Mkfs on it.  This is probably a place with Apple_Free 
partitions can
	  be put to good use since NetBSD doesn't recognize them as FFS disks.

One thing to keep in mind is the wide variation of options available to 
users with the disk formatters that are out there.  While it may be 
possible to create a disk partition of a type that works for you with 
your formatter, this option may not be available to others with different 
formatter software.

Hope this clears things up with respect to my previous posting, and I 
guess this is the announcement of the new version of "Mkfs_1.2" being 
available on puma and ftp.netbsd.org?

-bob