NetBSD/macppc Partitioning HOW-TO


This document is broken into four main parts:

  1. Introduction (Understanding Partitions)
  2. Partitioning a disk
  3. Creating a shared MS-DOS filesystem
  4. Partition nomenclature

Note: the Linux pdisk command does not properly set the flags for NetBSD/macppc. If you have already partitioned your disk using the Linux pdisk, you'll need to use the NetBSD pdisk to delete and re-create the NetBSD root and swap partitions.

Introduction (Understanding Partitions)

This document describes in depth how to partition a disk for use with NetBSD/macppc and MacOS. Whether you can boot your machine from a particular disk into a particular operating system depends on your machine's version of Open Firmware. The overall goal is to create an Apple Partition Map that Open Firmware can understand (and thus boot from) and that the NetBSD kernel can understand and use to find its root partition.

There are four tools to partition a disk: Apple's Drive Setup (MacOS 9), Apple's Disk Utility (MacOS X), NetBSD's pdisk(8) (all OSes), and NetBSD's disklabel(8) (NetBSD/macppc only). The first two tools (Drive Setup and Disk Utility) are distributed by Apple with MacOS and are located on bootable MacOS installation CDs. You can use them to partition a disk, create the filesystems, and to install MacOS bootloaders (called disk drivers in MacOS terminology).

The pdisk program is a command-line program which can be compiled and run on most unix-like systems (particularly the ones that run on PowerPC-based Macintosh and clone machines). This program can only partition a disk -- it can't install bootloaders or create filesystems.

NetBSD's disklabel creates a NetBSD-style disklabel(5). Unlike the other three tools, it can only create a fake Apple Partition Map (thus you can't use it to create a disk that's bootable by MacOS). That's OK, since some versions of Open Firmware require you to use disklabel to install the bootloader. Additionally, disklabel is the partition tool that is used in the NetBSD installer.

In the tables below, "yes" means the disk is bootable, "mount only" means that the OS can mount partitions on the disk, but cannot boot from it, and "no" means the OS can't mount partitions or boot from the disk.

Open Firmware 1.0.5 or 2.0.x
OS Drive Setup Disk Utility pdisk disklabel
NetBSD mount only mount only mount only yes
MacOS 9 yes yes no no
MacOS X and Darwin yes yes yes no
Linux yes yes? yes no

Open Firmware 2.4 or 3
OS Drive Setup Disk Utility pdisk disklabel
NetBSD yes yes yes no
MacOS 9 yes yes no no
MacOS X and Darwin yes yes yes no
Linux yes yes? yes no

The Apple Partition Map stores partition information as a numbered list (usually in order of location on disk). Partition "zero" is where the primary bootloader is stored for Open Firmware 1.0.5 or 2.0.x models. The partition map is partition number 1. A disk with MacOS 9 will usually have partitions 2 thru 8 reserved for its drivers. The user defined partitions (HFS, HFS+, UFS, NetBSD, etc.) will start at partition 9 (MacOS 9 disk), or 2 (no MacOS 9).

Keep in mind that Open Firmware uses Apple Partition Map numbers when determining the command to boot your machine into NetBSD/macppc. You can use pdisk to print out the Apple Partition Map, regardless of how it was created.

To make matters a little more confusing, NetBSD/macppc uses its own partition naming scheme, the letters 'a' thru 'h'. The root partition (regardless of its Apple Partition Map location) is partition 'a'. The swap partition is partition 'b'. Partition 'c' represents the whole disk. The '/usr' partition (if it exists) is partition 'g'. The rest of the partitions fill in the remainder of the letters.

See the section on Partition nomenclature below for a more thorough discussion.

There are a whole slew of filesystem types you may encounter. Briefly, HFS is Apple's old filesystem which has been in use since the '80s. HFS+ (also known as "extended") is an enhanced version of HFS which allows larger file (and filesystem) size, storage of unix-style owner and permissions. HFS+ is the recommended filesystem type for MacOS > 8.1, including MacOS X. UFS is Apple's NeXT-derived version of good old BSD FFS. MS-DOS (also known as FAT) is the filesystem standardized on the MS-DOS/Windows platform. BSD FFS is the standard filesystem used by most BSD unix-like OSes since the '80s (including NetBSD). ext2fs is the most common linux filesystem.

You may want to consider whether to include a partition that will be shared among your OSes. The most compatible format is MS-DOS FAT, but it lacks features (such as permissions and good repair tools). Unfortunately, NetBSD doesn't yet support the Macintosh HFS and HFS+ file systems natively. NetBSD-current has full support for Apple's UFS. Here's the quick breakdown:

format MacOS 8.1-9.x MacOS X and Darwin NetBSD Linux
Apple HFS yes yes hfstools yes (1)
Apple HFS+ yes yes no read-only (2)
Apple UFS no yes -current read-only
MS-DOS FAT File Exchange yes yes yes
BSD FFS no no yes read-only
Linux ext2fs no yes (3) yes yes

1 - Either use the stable hfsutils or the experimental in-kernel support.
2 - Either use the experimental hfsplus utils or the experimental linux-hfsplus kernel module.
3 - Use the highly experimental Ext2 Filesystem kernel extension.

If you want to create a partition you can share with MacOS 9, you should create an HFS partition which you will later convert to MS-DOS format. See Creating a shared MS-DOS filesystem after you've partitioned your disk.

If you don't care about Classic MacOS, then UFS is probably the best bet. Just make the UFS partition from within MacOS X or Darwin, and make sure you are using a -current NetBSD kernel. UFS will be supported in the next major release of NetBSD (i.e. not the 1.6.x branch).

Partitioning will erase the contents of your drive, so back up everything from the disk you will be partitioning. Follow the instructions for the partitioning tool you wish to use.

Partitioning using Drive Setup (MacOS 9)

  1. You will need to use Drive Setup version 1.8.1 or later. This is the version that comes with MacOS 9.0. If you are unsure, you need to select Drive Setup and pick Get Info from the File menu.

    drive setup

    If you have an older version of MacOS, you can download either the MacOS 9.0.4 (12.2 MB), MacOS 9.1 (71 MB), MacOS 9.2.1 (82 MB), or MacOS 9.2.2 (21.3 MB) updates, all of which include a version of Drive Setup that works for us. Note, these are big MacOS updates, so you will have to download a multi-megabyte disk image just to get the 500 KB Drive Setup application. Apple has not provided a recent version of Drive Setup as a standalone update.

    Also, the Darwin installer has a version of Drive Setup that works. Darwin is also enormous (120.7 MB), since it contains a complete operating system.

    You'll need to open the disk image and copy Drive Setup to a hard drive, RAM disk, Zip disk, or floppy disk (it can't run from the disk image).

  2. When you first run Drive Setup, it'll give you a screen like this, where you can select the drive that you want to re-partition.

    select a drive

    Select the drive to re-partition and click the Initialize... button. This will open another dialog box. Click the Custom Setup... button.

    initialize

  3. Select the number of partitions you'll be using. You will probably need at least 5 partitions, see the INSTALL notes for suggestions.

    custom setup

    Pick the Partitioning Scheme first since you lose all of your Volumes info each time you chose a different number of partitions.

  4. For each of the Volumes set the Type: under the Volume Info and Size: as suggested in the INSTALL notes.

    custom type

    You can use the TAB key to rotate through the Volumes.

  5. When you're done, you should have something like the following (you get to name the MacOS partitions later from the Finder):

    suggested layout

  6. Click the OK button. It will request confirmation of the changes.

    This is the point of no return! If you accept the changes, it will erase all contents of your drive

  7. After it's done partitioning and creating the HFS(+) partitions, it will return to the original screen.

    after partitioning

    Note: the A/UX partitions are not accessible to MacOS.

  8. You can quit Drive Setup, you're done with it. Now, from the Finder, you can rename your HFS(+) partitions. If you are using an Open Firmware 1.0.5 or 2.0.x model, you're done -- contine with the INSTALL notes.

    If your model has Open Firmware 2.4 or 3, and you're going to make this disk bootable for NetBSD, you still need to do one more step.

    You will need to copy ofwboot.xcf (the bootloader) and netbsd.GENERIC_MD.gz or netbsd.ram.gz (the installer) to one of the HFS(+) partitions on your drive. Make sure that you have downloaded these files in binary mode.

Partitioning using Disk Utility (MacOS X)

The MacOS X Disk Utility program cannot directly create NetBSD partitions, but where there's a will, there's a way. The advantage of Disk Utility is that it is available from the MacOS X install CDs. Disk Utility can only create "Mac OS Extended" (HFS+), "Mac OS Standard" (HFS), "UNIX File System" (UFS), and "Free Space" partitions.

NetBSD/macppc -current kernels can use UFS partitions, even as the root partition. At present, if there are no normal NetBSD A/UX-style partitions available, NetBSD/macppc does not fall back to assuming that an UFS partition is the root. You may need to figure out what partition NetBSD thinks the UFS is at (e.g. "e") and create a kernel with the UFS partition specified as the root device.

If this doesn't suit your needs, then you can use Disk Utility to create your MacOS HFS+ partitions and leave free space for NetBSD. You'll need to use pdisk to create the NetBSD partitions.

  1. Launch Disk Utility. From the install CDs, it's under the "Install" menu. From MacOS X, open /Applications/Utilities/Disk Utility.

  2. You may need to authenticate. If it says "Click the lock to make changes." in the lower left corner of the window, click the lock and type in your password (you are using an administrative account, aren't you).

  3. Select the disk to partition in the left panel. Click on the "Partition" tab. Pick your "Volume Scheme" (i.e. the number of partitions you want).

  4. Set the names, formats, and sizes of your partitions. Hint: to make partitions smaller than it recommends, type a number into the size box and hit enter to get it to accept your partition size. "Mac OS Extended" HFS+ partitions have a minimum size of 4 MB. For example, on my two-partition disk (a small HFS partition for ofwboot.xcf and a large UFS partition for NetBSD), Disk Utility looks like this:

    small HFS partition

    large NetBSD UFS partition

  5. Choose whether to install MacOS 9 disk drivers. This is your only opportunity if you think you'll ever want to access any partitions on this disk from MacOS 9 or earlier. Even HFS partitions are inaccessible from MacOS 9 if you don't click this button.

  6. Click OK and follow through.

  7. You can quit Disk Utility, you're done with it. Now, from the Finder, you can rename your HFS(+) and UFS partitions. If you are using an Open Firmware 1.0.5 or 2.0.x model, you're done -- contine with the INSTALL notes.

    If your model has Open Firmware 2.4 or 3, and you're going to make this disk bootable for NetBSD, you still need to do one more step.

    You will need to copy ofwboot.xcf (the bootloader) to one of the HFS(+) partitions on your drive. Copy netbsd.GENERIC_MD.gz (the installer) to your UFS partition (though it can also sit on an HFS(+) partition). Make sure that you have downloaded these files in binary mode.

    Remember, you'll need a -current kernel to use UFS as a root partition, and it may not be recognized by NetBSD as partition "a".

Partitioning using pdisk and newfs (MacOS 9, MacOS X, Darwin, NetBSD, Linux)

The command-line pdisk utility is used to view and modify the Apple Partition Map on a disk. NetBSD, MacOS X, and Darwin can all mount disks partitioned with pdisk. MacOS 9 and earlier need special drivers to be installed to mount a disk (see Drive Setup and Disk Utility). pdisk can create partition maps which will be bootable on Open Firmware 2.4 or 3 machines running NetBSD, MacOS X, and Darwin.

You may still find pdisk useful to modify a partition map created by another utility or simply to list the partition map of a disk. If you are merely interested in listing the partition map of a disk, follow steps 1 through 4.

Before starting, some caveats about partitioning:

The partition numbers listed by pdisk are the same that Open Firmware uses. If you're trying to boot an Open Firmware 2.4 or 3 machine with this disk, remember which Apple_HFS partition number has ofwboot.xcf and which Apple_UNIX_SVR2 or Apple_UFS partition is your NetBSD root partition.

  1. Get pdisk.

  2. Determine the device name for the disk you're going to repartition or view. If you are repartitioning, unmount any of those disk's partitions that might be mounted.

  3. Run pdisk /dev/disk-device, where disk-device is something like:
      # ./pdisk /dev/disk2
      Edit /dev/disk2 -
      Command (? for help): ?
      Notes:
        Base and length fields are blocks, which vary in size between media.
        The base field can be <nth>p; i.e. use the base of the nth partition.
        The length field can be a length followed by k, m, g or t to indicate
        kilo, mega, giga, or tera bytes; also the length can be <nth>p; i.e. use
        the length of the nth partition.
        The name of a partition is descriptive text.
      
      Commands are:
        C    (create with type also specified)
        c    create new partition (standard unix root)
        d    delete a partition
        h    help
        i    initialize partition map
        n    (re)name a partition
        P    (print ordered by base address)
        p    print the partition table
        q    quit editing
        r    reorder partition entry in map
        s    change size of partition map
        t    change a partition's type
        w    write the partition table

  4. Double-check you're on the right disk. If it's already got an Apple Partition Map, everything should be OK.
      Command (? for help): P
    
      Partition map (with 512 byte blocks) on '/dev/disk0'
       #:                type name             length   base    ( size )
       1: Apple_partition_map Apple                63 @ 1      
       2:      Apple_Driver43*Macintosh            56 @ 64     
       3:      Apple_Driver43*Macintosh            56 @ 120    
       4:    Apple_Driver_ATA*Macintosh            56 @ 176    
       5:    Apple_Driver_ATA*Macintosh            56 @ 232    
       6:      Apple_FWDriver Macintosh           512 @ 288    
       7:  Apple_Driver_IOKit Macintosh           512 @ 800    
       8:       Apple_Patches Patch Partition     512 @ 1312   
       9:          Apple_Free                     192 @ 1824   
      10:           Apple_UFS shared          1700000 @ 2016    (830.1M)
      11:           Apple_HFS macos            408788 @ 1702016 (199.6M)
      12:          Apple_Free                       8 @ 2110804
    
      Device block size=512, Number of Blocks=2110812 (1.0G)
      DeviceType=0x0, DeviceId=0x0
      Drivers-
      1:  23 @ 64, type=0x1
      2:  36 @ 120, type=0xffff
      3:  21 @ 176, type=0x701
      4:  34 @ 232, type=0xf8ff
    If the disk does not have an APM, it'll give you some errors and you'll need to initialize the APM before creating new partitions.
      Command (? for help): P
      No partition map exists
      Command (? for help): i
      read failed
      Command (? for help): P
    
      Partition map (with 512 byte blocks) on '/dev/rdisk2'
       #:                type name    length   base    ( size )
       1: Apple_partition_map Apple       63 @ 1      
       2:          Apple_Free Extra  2110749 @ 64      (1.0G)
    
      Device block size=512, Number of Blocks=2110812 (1.0G)
      DeviceType=0x0, DeviceId=0x0

  5. Delete unused partitions and create your partitions. There's no need to delete the Apple_Free partitions, those automatically take up any unassigned space.

    Use the P command to list the partitions to make sure you delete the right one(s).

      Command (? for help): d
      Partition number: 9
    Useful partition types you might want to create are:

    Apple_HFS HFS and HFS+ partitions (also shared MS-DOS)
    Apple_UFS UFS partitions
    Apple_UNIX_SVR2 A/UX-style partition for NetBSD and Linux

      Command (? for help): C
      First block: 2p
      Length in blocks: 100m
      Name of partition: Zathras
      Type of partition: Apple_HFS
      Command (? for help): C
      First block: 3p
      Length in blocks: 800m
      Name of partition: netbsd
      Type of partition: Apple_UNIX_SVR2
      Available partition slices for Apple_UNIX_SVR2:
        a   root partition
        b   swap partition
        c   do not set any bzb bits
        g   user partition
      Other lettered values will create user partitions
      Select a slice for default bzb values: a
      Command (? for help): C
      First block: 4p
      Length in blocks: 4p
      Name of partition: swap
      Type of partition: Apple_UNIX_SVR2
      Available partition slices for Apple_UNIX_SVR2:
        a   root partition
        b   swap partition
        c   do not set any bzb bits
        g   user partition
      Other lettered values will create user partitions
      Select a slice for default bzb values: b
      Command (? for help): P
    
      Partition map (with 512 byte blocks) on '/dev/rdisk0'
       #:                type name     length   base    ( size )
       1: Apple_partition_map Apple        63 @ 1      
       2:           Apple_HFS Zathras  204800 @ 64      (100.0M)
       3:     Apple_UNIX_SVR2 netbsd  1638400 @ 204864  (900.0M) S0 RUFS k0  /
       4:     Apple_UNIX_SVR2 swap     267548 @ 1843264 (130.6M) S1  SFS k0  (swap)
    
      Device block size=512, Number of Blocks=2110812 (1.0G)
      DeviceType=0x0, DeviceId=0x0

  6. Write out the new partition map and quit.
      Command (? for help): w
      Writing the map destroys what was there before. Is that okay? [n/y]: y
      Command (? for help): q

  7. Create new filesystems.

  8. Mount your new filesystems.

  9. If you are using an Open Firmware 1.0.5 or 2.0.x model, you may want to copy netbsd.GENERIC_MD.gz (the installer) to your FFS or UFS partition. Make sure that you have downloaded this file in binary mode. You'll still need to load ofwboot.xcf from another source to boot your machine, though.

    If your model has Open Firmware 2.4 or 3, and you're going to make this disk bootable for NetBSD, you will need to copy ofwboot.xcf (the bootloader) to one of the HFS(+) partitions on your drive. From NetBSD, use the hcopy command. Copy netbsd.GENERIC_MD.gz (the installer) to your FFS or UFS partition (though it can also sit on an HFS(+) partition). Make sure that you have downloaded these files in binary mode.

    Remember, you'll need a -current kernel to use UFS as a root partition, and it may not be recognized by NetBSD as partition "a".

Creating a shared MS-DOS filesystem

You can create an MS-DOS format partition that works in all OSes such that classic MacOS will automatically mount it, and the unix-like OSes (NetBSD, Linux, Darwin, and MacOS X) can mount it using the mount_msdos command. The steps below outline the most straightforward technique.

  1. Partition your hard drive with an HFS partition (type Apple_HFS) reserved for MS-DOS.

  2. Next, boot MacOS 8.1-9.x, grab a copy of Disk Charmer or DiskCharmer, and set it up to create an MS-DOS file system. Your settings should look something like this:

    screenshot of DiskCharmer

  3. Drag the partition onto DiskCharmer's window and it will prompt you before erasing it and creating an MS-DOS file system in place of the HFS file system you created in the first step.

  4. Now, when you boot Classic MacOS, this partition will automatically mount using PC Exchange or File Exchange (depending on what it's called in your version of MacOS).

    When you boot into MacOS X, Linux, or NetBSD, run the following command:

    mkdir -p /msdos.filesystem;/sbin/mount_msdos -m 777 /dev/disk0s11 /msdos.filesystem
    where /msdos.filesystem is the mount point you'd like, and /dev/disk0s11 is the device name for your partition. Alternatively, for NetBSD and Linux, you can add an entry to your /etc/fstab to always mount this filesystem.

  5. To get MacOS X and Darwin to automatically mount your MS-DOS file system, you need to create a System Startup bundle. The SystemStarter HOWTO is a good reference if you want to learn more about creating your own startup bundles. There's probably a way to do this using autodiskmount, but this technique works fine. The only downside is that the MS-DOS filesystem is unavailable to the Classic environment. Here's an example of what to do:

    1. # mkdir -p /Library/StartupItems/MountMSDOS

    2. Create /Library/StartupItems/MountMSDOS/StartupParameters.plist with the following contents:
      {
        Description     = "Mount MSDOS partitions";
        Provides        = ("Manual MSDOS partitions");
        Requires        = ("Disks");
        OrderPreference = "None";
        Messages =
        {
          start = "Mounting MSDOS partitions";
          stop  = "Unmounting MSDOS partitions";
        };
      }

    3. Create /Library/StartupItems/MountMSDOS/MountMSDOS with the following contents:
      #!/bin/sh
      
      . /etc/rc.common
      
      ##
      # Manually mount HFS partition with MS-DOS filesystem
      ##
      
      ConsoleMessage "Mount MS-DOS partitions"
      
      ##
      # Mount your filesystems manually.
      ##
      mount_msdos /dev/disk0s11 /Volumes/Thingies

    4. # chown -R root /Library/StartupItems/MountMSDOS
      # chmod a+rx /Library/StartupItems/MountMSDOS/MountMSDOS

Partition nomenclature

There are three partition identification schemes you'll run across when using NetBSD/macppc. Each identification scheme sorts the partitions differently, even though the partition's location on the disk doesn't change. Some schemes hide certain partitions.

  1. Actual order on the disk (0 thru max partition number):
    This is the scheme used by Open Firmware and the /dev/diskXsY device files in MacOS X and Darwin. The order of partitions is directly related to the order you selected in Drive Setup, pdisk, or the NetBSD partitioning tools. You can print out this list from any OS using pdisk.

    0 A special "partition" reserved for a primary bootloader.
    1 The Apple Partition Map.
    2 thru ~8 Reserved for MacOS 9 drivers if the drive is formatted with a MacOS tool. Otherwise, user created partitions.
    ~9 thru ~15 User created partitions, placed in order of their physical location on disk.

  2. MacOS-visible partitions (by partition name in Finder):
    While you may have created a bunch of partitions in Drive Setup, only those partitions visible to MacOS will show up in the Finder.

    The only partitions visible to MacOS 9 and earlier are those formatted in HFS, HFS+, or MS-DOS formats. The only partitions visible to MacOS X and later are those formatted in HFS, HFS+, UFS, and MS-DOS (not NetBSD's 4.2BSD FFS).

  3. NetBSD-visible partitions (letters a thru h, as seen by disklabel):
    NetBSD reorders the partitions such that things work out better for itself. The fstype reported by disklabel(8) is set by the Apple Partition Map flags, and does not depend on the actual type of filesystem on that partition (be it NetBSD FFS, Apple HFS, or MS-DOS). In particular, MS-DOS formatted partitions show up as HFS partitions, if created using the method in Creating a shared MS-DOS filesystem.

    a Your "A/UX Root" partition, regardless of its order on the disk
    b Your "A/UX Swap" partition, regardless of its order on the disk
    c This is the entire disk (first sector to last sector)
    d-f First few non-A/UX partitions (usually the user HFS(+) partitions)
    g Your "A/UX User" partition (if present), regardless of its order on the disk
    h Additional non-A/UX partitions (usually user HFS(+) partitions)

So, for example the following is what Drive Setup created on my PowerBook (FireWire):

MacOSOF/OSXNetBSD CommentApple Partition Map type disklabel fstype

0
bootloader


1
Partition map Apple_partition_map Apple unknown

2
MacOS driver Apple_Driver43*Macintosh unknown

3
MacOS driver Apple_Driver43*Macintosh unknown

4
MacOS driver Apple_Driver_ATA*Macintosh unknown

5
MacOS driver Apple_Driver_ATA*Macintosh unknown

6
MacOS driver Apple_FWDriver Macintosh unknown

7
MacOS driver Apple_Driver_IOKit Macintosh unknown

8
MacOS driver Apple_Patches Patch Partition unknown
Untitled 9 d MacOS 9 boot partition Apple_HFS untitled HFS
Untitled 2 10 e MacOS X boot partition Apple_HFS untitled 2 HFS
Untitled 3 11 f MS-DOS shared partition Apple_HFS untitled 3 HFS

12 a NetBSD boot partition Apple_UNIX_SVR2 A/UX Root 4.2BSD

13 b NetBSD swap Apple_UNIX_SVR2 Swap swap

14 g unused disk space Apple_Free Extra unknown


c NetBSD whole disk
unused

After installation, one of the HFS partitions, "Untitled" (which is partition 9 to Open Firmware, and partition d to NetBSD) has ofwboot.xcf, and one of the A/UX partitions (which is partition 12 to Open Firmware, and partition a to NetBSD) has my NetBSD kernel, so I use the following command to boot:

boot hd:9,ofwboot.xcf hd:12

NetBSD Home Page
NetBSD Supported Architectures

www@NetBSD.org
$NetBSD: partitioning.html,v 1.16 2004/10/30 22:33:48 jschauma Exp $
Copyright © 1998-2003 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.