macOS’ Disk Utility sucks, here’s how to use a CLI to partition instead

1 Jan '17

I recently found out that Apple’s Disk Utility won’t allow multiple partitions with a Master Boot Record. This is incredibly annoying. But the CLI will.

Warning: There is no confirmation, no “are you sure?” prompts. diskutil will mess your disks up, zero fucks given. You need to double and triple check the commands you issue. That is all.

$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME         \
     SIZE       IDENTIFIER
   0:      GUID_partition_scheme              \
    *121.3 GB   disk0
   1:                        EFI EFI          \
     209.7 MB   disk0s1
   2:          Apple_CoreStorage XXX          \
     120.5 GB   disk0s2
   3:                 Apple_Boot Recovery HD  \
     650.0 MB   disk0s3

[...]

/dev/disk2 (external, physical):
   #:                       TYPE NAME         \
     SIZE       IDENTIFIER
   0:      GUID_partition_scheme              \
    *2.0 TB     disk2
   1:                        EFI EFI          \
     209.7 MB   disk2s1
   2:                  Apple_HFS one          \
     1.8 TB     disk2s2
   3:                  Apple_HFS two          \
     249.7 GB   disk2s3

This command will be your friend, a lifesaver. Learn to love it. It shows the disks attached to the computer. You’re most interested in the value in the IDENTIFIER column, but the other columns will help you figure out what’s what.

In this case, we’ve got two physical disks, one internal disk and one external. Do not touch the internal disk, this is your hard drive.

To partition a disk, use the partitionDisk subcommand. The help is actually rather good. To view which filesystems you can create, you’ll also need the listFilesystems subcommand.

$ diskutil partitionDisk -h
[...]
$ diskutil listFilesystems
[...]

Briefly, you need:

For partition size, you can use decimal numbers with the suffixes B, K, M, G, T, P (bytes, kilobytes, megabytes, gigabytes, terabytes or petabytes), % of the disk size, or R for remainder.

These examples show you how to create one, two or three partitions:

$ sudo diskutil partitionDisk disk3 1 \
    JHFS+ one R
$ sudo diskutil partitionDisk disk3 2 GPT \
    JHFS+ one R \
    JHFS+ two 250G
$ sudo diskutil partitionDisk disk3 MBR \
    JHFS+ one R \
    JHFS+ two 250G \
    ExFAT three 10G

macOS

Newer Older