Subject: Re: apple partition map questions
To: Neil Ludban <nludban@columbus.rr.com>
From: Bill Studenmund <wrstuden@netbsd.org>
List: port-macppc
Date: 09/23/2002 15:17:26
On Sun, 22 Sep 2002, Neil Ludban wrote:

> Hello,
>
> I've been trying for some time now to turn my bondi-blue iMac into
> a dedicated NetBSD workstation, bootable from the hard drive.  This
> has turned out to be quite an adventure, with my lack of prior Mac
> experience, no MacOS CDs, and ethernet and CD each failing to boot
> about 80% of the time :(
>
> What I'm attempting now is to convert the drive to using an Apple
> partition map, the theory being that I would then be able to format
> the HFS partition and copy in ofwboot.xcf using hfsutils.  Note
> the free space at the start of the disk, partition h:
>
> ===
> #     size   offset   fstype [fsize bsize cpg/sgs]
> a:  524475   524475   4.2BSD   1024  8192    16   # (Cyl.  925 - 1849)
> b:  524475  1048950     swap                      # (Cyl. 1850 - 2774)
> c: 8418816        0   unused      0     0         # (Cyl.    0 - 14847)
> e: 3072006  1573425   4.2BSD   1024  8192    16   # (Cyl. 2775 - 8192)
> f: 3773385  4645431   4.2BSD   1024  8192    16   # (Cyl. 8193 - 14847)
> h:  524475        0   unused      0     0         # (Cyl.    0 - 924)
> ===
>
> I've hacked together a small Python program that takes the above as
> input and produces the equivalent APM (in ascii and hex):
>
> ===
> Total disk size = 8418816 sectors.
> Apple Partition Map:
> Block Zero {
>         sbBlkCount      8418816
> }
> Partition[0] {
>         MapBlkCnt       6
>         PyPartStart     1
>         PartBlkCnt      16
>         PartName        Apple
>         PartType        Apple_partition_map
>         DataCnt         16
> }
> Partition[1] {
>         MapBlkCnt       6
>         PyPartStart     17
>         PartBlkCnt      524458
>         PartName        MacOS
>         PartType        Apple_HFS
>         DataCnt         524458
> }
> Partition[2] {
>         MapBlkCnt       6
>         PyPartStart     524475
>         PartBlkCnt      524475
>         PartName        A/UX Root
>         PartType        Apple_UNIX_SVR2
>         DataCnt         524475
> }
> Partition[3] {
>         MapBlkCnt       6
>         PyPartStart     1048950
>         PartBlkCnt      524475
>         PartName        Swap
>         PartType        Apple_UNIX_SVR2
>         DataCnt         524475
> }
> Partition[4] {
>         MapBlkCnt       6
>         PyPartStart     1573425
>         PartBlkCnt      3072006
>         PartName        A/UX User
>         PartType        Apple_UNIX_SVR2
>         DataCnt         3072006
> }
> Partition[5] {
>         MapBlkCnt       6
>         PyPartStart     4645431
>         PartBlkCnt      3773385
>         PartName        A/UX Home
>         PartType        Apple_UNIX_SVR2
>         DataCnt         3773385
> }
>
>
> 0000  45 52 02 00 00 80 76 00  00 00 00 00 00 00 00 00  |ER....v.........|
> 0010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> *
> 0200  50 4d 00 00 00 00 00 06  00 00 00 01 00 00 00 10  |PM..............|
> 0210  41 70 70 6c 65 00 00 00  00 00 00 00 00 00 00 00  |Apple...........|
> 0220  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 0230  41 70 70 6c 65 5f 70 61  72 74 69 74 69 6f 6e 5f  |Apple_partition_|
> 0240  6d 61 70 00 00 00 00 00  00 00 00 00 00 00 00 00  |map.............|
> 0250  00 00 00 00 00 00 00 10  00 00 00 00 00 00 00 00  |................|
> 0260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> *
> 0400  50 4d 00 00 00 00 00 06  00 00 00 11 00 08 00 aa  |PM..............|
> 0410  4d 61 63 4f 53 00 00 00  00 00 00 00 00 00 00 00  |MacOS...........|
> 0420  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 0430  41 70 70 6c 65 5f 48 46  53 00 00 00 00 00 00 00  |Apple_HFS.......|
> 0440  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 0450  00 00 00 00 00 08 00 aa  00 00 00 00 00 00 00 00  |................|
> 0460  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> *
> 0600  50 4d 00 00 00 00 00 06  00 08 00 bb 00 08 00 bb  |PM..............|
> 0610  41 2f 55 58 20 52 6f 6f  74 00 00 00 00 00 00 00  |A/UX Root.......|
> 0620  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 0630  41 70 70 6c 65 5f 55 4e  49 58 5f 53 56 52 32 00  |Apple_UNIX_SVR2.|
> 0640  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 0650  00 00 00 00 00 08 00 bb  00 00 00 00 00 00 00 00  |................|
> 0660  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> *
> 0800  50 4d 00 00 00 00 00 06  00 10 01 76 00 08 00 bb  |PM.........v....|
> 0810  53 77 61 70 00 00 00 00  00 00 00 00 00 00 00 00  |Swap............|
> 0820  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 0830  41 70 70 6c 65 5f 55 4e  49 58 5f 53 56 52 32 00  |Apple_UNIX_SVR2.|
> 0840  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 0850  00 00 00 00 00 08 00 bb  00 00 00 00 00 00 00 00  |................|
> 0860  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> *
> 0a00  50 4d 00 00 00 00 00 06  00 18 02 31 00 2e e0 06  |PM.........1....|
> 0a10  41 2f 55 58 20 55 73 65  72 00 00 00 00 00 00 00  |A/UX User.......|
> 0a20  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 0a30  41 70 70 6c 65 5f 55 4e  49 58 5f 53 56 52 32 00  |Apple_UNIX_SVR2.|
> 0a40  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 0a50  00 00 00 00 00 2e e0 06  00 00 00 00 00 00 00 00  |................|
> 0a60  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> *
> 0c00  50 4d 00 00 00 00 00 06  00 46 e2 37 00 39 93 c9  |PM.......F.7.9..|
> 0c10  41 2f 55 58 20 48 6f 6d  65 00 00 00 00 00 00 00  |A/UX Home.......|
> 0c20  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 0c30  41 70 70 6c 65 5f 55 4e  49 58 5f 53 56 52 32 00  |Apple_UNIX_SVR2.|
> 0c40  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 0c50  00 00 00 00 00 39 93 c9  00 00 00 00 00 00 00 00  |.....9..........|
> 0c60  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> *
> ===
>
> Questions so far:
>
> 0) It seems too easy... is this approach doomed to failure?

Loks ok in principle.

> 1) Are the special Apple partitions required? (FAQs say no, but I've
>    not found any samples)

None that you aren't making (the hfs to hold ofwboot.xcf could be
considered a special partition. :-)

> 2) Are any flags missing, especially wrt being bootable?  (I followed
>    libhfs' examples, need to look at pdisk too)

Not sure. I think you'll need some special flags set to get the swap
partition right.

Send me the new partition map as a file, and I'll see what I can do.

> 3) Does NetBSD expect any flags set?  (ISTR mention of block and
>    fragment sizes, or maybe it was just a proposal)
> 4) Is NetBSD limited to root, swap, and usr partitions?

Yes, but "root" and "usr" only means that they default to partition a or
partition g respectively. That doesn't mean there can be only one of
either.

> 5) Is HFS also not caring about drive geometry?  Could a raw HFS
>    partition (small (<1M) and bootable with ofwboot.xcf) just be
>    copied onto a new drive and still work?

I think that will work.

> 6) What's a safe way to overwrite the NetBSD disklabel with the APM,
>    so the kernel doesn't get confused or panic?

Boot single-user, write the above to disk, reboot.

Take care,

Bill