This document is broken into four main parts:
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.
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.
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).
Select the drive to re-partition and click the Initialize... button. This will open another dialog box. Click the Custom Setup... button.
Pick the Partitioning Scheme first since you lose all of your Volumes info each time you chose a different number of partitions.
You can use the TAB key to rotate through the Volumes.
This is the point of no return! If you accept the changes, it will erase all contents of your drive
Note: the A/UX partitions are not accessible to MacOS.
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.
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.
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".
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.
# ./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
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=0xf8ffIf 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
Use the P command to list the partitions to make sure you delete the right one(s).
Command (? for help): d Partition number: 9Useful 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
Command (? for help): w Writing the map destroys what was there before. Is that okay? [n/y]: y Command (? for help): q
# /sbin/autodiskmount -v ** /dev/rdisk2s2 FILESYSTEM CLEAN; SKIPPING CHECKS ** /dev/rdisk2s5 QUICKCHECK ONLY; FILESYSTEM CLEAN Mounted ufs /dev/disk0s5 on /Volumes/untitled DiskDev Type FileSys Fixed Write Volume Name Mounted On disk2s2 ??? hfs yes yes untitled /Volumes/untitled disk2s5 ??? ufs yes yes untitled /Volumes/untitled 1 disk0s10 ??? hfs yes yes OSX /
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".
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.
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.filesystemwhere /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.
{ Description = "Mount MSDOS partitions"; Provides = ("Manual MSDOS partitions"); Requires = ("Disks"); OrderPreference = "None"; Messages = { start = "Mounting MSDOS partitions"; stop = "Unmounting MSDOS partitions"; }; }
#!/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
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.
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. |
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).
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):
MacOS | OF/OSX | NetBSD | Comment | Apple 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
|
|