MAC-FDISK(8)

๐Ÿ“ฆ version 0.1.16, in nixos 26.05

๐Ÿ’พ mac-fdisk(8) โ€” Apple Disk Partitioning Manual ๐Ÿ’พ

okay so hi bestie ๐Ÿซถ welcome to the mac-fdisk page, straight out of the Apple Disk Partitioning Manual. this is the one that lives in section 8 of the manual, and it's about to be your new fave little partition gremlin.


โœจ NAME โœจ

mac-fdisk โ€” Apple partition table editor for Linux ๐Ÿ’…


โœจ SYNOPSIS โœจ

mac-fdisk [ -h | --help ] [ -v | --version ] [ -l | --list device ... ]
mac-fdisk [ -r | --readonly ] device ...

โœจ DESCRIPTION โœจ

so mac-fdisk is a command line type program โ€” very terminal, very demure โ€” that partitions disks using the standard Apple disk partitioning scheme as described in "Inside Macintosh: Devices". no cap, that's the source. ๐Ÿ“š

the device is usually one of these icons right here:

/dev/sda
/dev/sdb
/dev/sdc
/dev/sdd
/dev/sde
/dev/sdf
/dev/sdg
/dev/hda
/dev/hdb

quick vibe check on how that naming works ๐ŸŒ€ โ€” /dev/sda is the first hard disk on the SCSI bus (i.e. the one with the lowest id), /dev/sdb is the second hard disk, and so on down the line.

now the part that trips people up: a partition is a device name followed by a partition number. that number is the index (starting from one) of the partition map entry in the partition map โ€” and heads up, the partition map itself occupies the first entry. ๐Ÿ™ˆ so for example, /dev/sda2 is the partition described by the second entry in the partition map on /dev/sda. (yes, the original really does spell it "partiton map" in that sentence. we love a typo era. ๐Ÿ’€)


โœจ OPTIONS โœจ

  • -v | --version โ€” prints the version number of the mac-fdisk program. ๐Ÿท๏ธ
  • -h | --help โ€” prints a list of available commands for the mac-fdisk program. ๐Ÿ†˜
  • -l | --list โ€” lists the partition tables for the specified device(s). and if you give it no device(s) at all? it lists all SCSI and IDE devices found in the system. โญ
  • -r | --readonly โ€” prevents mac-fdisk from writing to the device. ๐Ÿ›ก๏ธ read-only queen behavior, we stan a safe queen.

๐ŸŽ€ Editing Partition Tables ๐ŸŽ€

okay here's the fun part. ๐Ÿ’– if an argument is just simply the name of a device, that means mac-fdisk should edit the partition table of that device.

once it's started, mac-fdisk hits you with an interactive command prompt for editing the partition table. the partition editing commands are:

h    list available commands
p    print (list) the current edited partition table status
P    print ordered by base address
i    initialize the partition map
s    change size of partition map
b    create new 800K Apple_Bootstrap partition (used by yaboot)
c    create new standard Linux type partition
C    create new partition, specifying the partition type
d    delete a partition
r    reorder partition entry
w    write the partition table to disk
q    quit

note that lowercase p and uppercase P are different commands, and lowercase c and uppercase C are also different. it's giving case-sensitive girly. ๐Ÿ’…

commands that take arguments will prompt for each argument in turn. but bestie, you can also just type the arguments separated by spaces and those prompts get skipped entirely. efficiency icon. โšก

the i and w commands will prompt for confirmation. and here's the big one: none of the editing you do will actually affect the state of the disk you are partitioning until the w command is issued. then the map, in its edited state, gets permanently written to the disk. permanent. forever. no undo. ๐Ÿ˜ญ

partitions are always specified by their number โ€” the index of the partition entry in the partition map. and listen, many commands will change the index numbers of partitions which follow the affected partition, so you are encouraged to use the p command to print the partition table as frequently as necessary. spam it. it's free. ๐ŸŒ€

โš ๏ธ limits alert: for SCSI disks, the partition table should not contain more than fifteen partitions (partition map excluded). IDE disks have a limit of 31 partitions.

here is a more-or-less typical output for the print command ๐Ÿ‘€ :

Command (? for help): p
/dev/sdb
        #                type name              length   base    ( size )  system
/dev/sdb1 Apple_partition_map Apple                 63 @ 1       ( 31.5k)  Partition map
/dev/sdb2      Apple_Driver43 Macintosh             54 @ 64      ( 27.0k)  Driver 4.3
/dev/sdb3      Apple_Driver43 Macintosh             74 @ 118     ( 37.0k)  Driver 4.3
/dev/sdb4  Apple_Driver_IOKit Macintosh            512 @ 192     (256.0k)  Unknown
/dev/sdb5       Apple_Patches Patch Partition      512 @ 704     (256.0k)  Unknown
/dev/sdb6           Apple_HFS untitled         3072000 @ 1216    (  1.5G)  HFS
/dev/sdb7           Apple_HFS untitled 2        333026 @ 3073216 (162.6M)  HFS
/dev/sdb8          Apple_Free Extra                 10 @ 3406242 (  5.0k)  Free space

Block size=512, Number of Blocks=3406252
DeviceType=0x0, DeviceId=0x0
Drivers-
1: @ 64 for 22, type=0x1
2: @ 118 for 36, type=0xffff

๐Ÿงš the i command

the i (initialize) command prompts for the size of the device. you can just hit Return to accept the offered size, which should be correct. ๐Ÿซถ

๐Ÿงš the b command

the b command is a shortcut to create the bootstrap partition used on PowerPC NewWorld machines. it's equivalent to creating an 800k Apple_Bootstrap type partition using the C command described below.

the sole purpose of this partition is to store the boot loader. ๐Ÿ‘‘

in multiboot environments, the first bootable partition found on the disk takes precedence โ€” unless a specific boot partition is set in OpenFirmware. so it's best to:

  • create the bootstrap partition first, or
  • move it to a position before any Apple_HFS or Apple_Boot partitions using the r command described below

then you'll still be able to boot Linux after the occasional OpenFirmware reset. ๐Ÿ˜ฎโ€๐Ÿ’จ crisis averted.

๐Ÿงš the c command

the c (create new partition) command has three arguments. and as mentioned up top, you can type the arguments following the command separated by spaces, or just respond to the prompts for each argument:

  1. the base address of the start of the partition. you can specify a number in blocks (most likely reading from the existing partition map) โ€” or you can type a partition number followed by the letter p to indicate that the new partition should take the place of that existing free space partition. ๐Ÿ“
  2. the length of the partition. again, you can specify a number in blocks, or type a partition number followed by the letter p to indicate use of the entire partition. you can also type a number followed by k, m, or g to indicate the size in kilobytes, megabytes, or gigabytes respectively. (these are powers of 1024, of course, not powers of 1000. respectful. ๐Ÿซก) ๐Ÿ“
  3. the name of the partition. this can be a single word without quotes, or a string surrounded by single or double quotes. it is best to name any swap partition you create swap ๐Ÿ“ โ€” other partition names are up to you. and ngl, the names are not visible to Linux. ๐Ÿ’€

๐Ÿงš the C command

the C command is identical to the c command, with the addition of a partition type argument after the other arguments.

the partition type used for Linux swap and data partitons is APPLE_UNIX_SVR2 โ€” this is the partition type created by the c command. (yep, "partitons" again. iconic typo, keeping it. ๐ŸŽ€)

under normal circumstances, you should not need to use this command. it's giving optional bonus level. ๐Ÿฆ‹

๐Ÿงš the d command

the d command deletes the partition number specified, replacing that partition with partitionable free space. ๐Ÿ—‘๏ธ

๐Ÿงš the r command

the r (reorder) command allows the index number of partitions to be changed.

the index numbers are constrained to be a contiguous sequence, and mac-fdisk will enforce this constraint by recalculating the partition numbers after each insert, delete or reorder operation.

here's the iykyk part ๐Ÿ‘‘ โ€” OpenFirmware looks for bootable partitions in the order specified by the index. but the partitions are not moved on the disk. this command takes two arguments: the number of the partition to be moved, and the partition number it should become.

๐Ÿงš the w command

the w command writes the partition map out to disk. ๐Ÿ’พ

โš ๏ธ note that partition maps for disks with mounted partitions cannot immediately be reinterpreted by the kernel. in order to use the new partition map, you must reboot. ๐Ÿ˜ญ

within the Debian installer system, mac-fdisk is normally invoked before any partitions are mounted, so a reboot is not necessary before continuing the installation. we love a convenient installer flow. ๐ŸŒˆ

๐Ÿงš the q command

the q command terminates the program. and if there was no w command issued during the program run, then there will be no effect on the disk. no harm, no foul, nothing written. โœจ


๐Ÿ’€ BUGS ๐Ÿ’€

some people believe there should really be just one disk partitioning utility. (a bold take. a controversial take. we're just reporting it. ๐Ÿ™ˆ)

and here's the real one, bestie โ€” mac-fdisk should be able to create HFS partitions that work. currently, if a pre-existing HFS partition is resized, MacOS will continue to use the partition size stored in the HFS 'superblock' instead of using the size from the partition table. (the MacOS volume on the partition remains valid even though the sizes don't match anymore. ๐Ÿ’€)

this can have undesired side effects, especially when creating a smaller HFS partition followed by a few Linux partitions in place of the previous HFS partition space. ๐Ÿ˜ญ

๐Ÿ’ก to avoid this issue: create MacOS partitions within MacOS and then don't resize them in mac-fdisk. periodt. ๐ŸŽ€

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

fdisk(8), mkswap(8), mkfs(8) โ€” go read those next, bestie, they're the whole friend group. ๐Ÿซถ


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Eryk Vershen (eryk@apple.com), and the man page was revised by Chris Tillman (tillman@azstarnet.com). legends, both of them. ๐Ÿ†


and that's the page, bestie!! ๐Ÿฆ‹ this one shipped with Debian, dated 1 December 2001, and it lives happily at MAC-FDISK(8). now go partition something responsibly โ€” and remember, don't hit w until you mean it ๐Ÿ’…โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from