diskutil — Manage Disks and Volumes

Practical guide to diskutil — manage macOS disks, volumes and partitions: list, format, mount, verify, repair and handle APFS containers.

diskutil is the command-line counterpart to Disk Utility and your central tool for managing disks, volumes and partitions on macOS straight from the terminal. You list devices, mount and unmount volumes, format them and verify or repair filesystems – and you create, resize or snapshot APFS containers along the way. This guide takes you from the harmless listing and info commands to the powerful format and partition operations you should handle with care.

List & Info

diskutil list — List all disks and partitions.

diskutil list

diskutil list internal — List only internal disks.

diskutil list internal

diskutil list external — List only external disks.

diskutil list external

diskutil info <disk> — Show detailed info about a disk or partition.

diskutil info disk0s1

diskutil info -all — Show info for all disks.

diskutil info -all

diskutil activity — Monitor disk activity in real-time.

diskutil activity

Mount & Unmount

diskutil mount <disk> — Mount a volume.

diskutil mount disk2s1

diskutil mountDisk <disk> — Mount all volumes on a disk.

diskutil mountDisk disk2

diskutil unmount <disk> — Unmount a volume.

diskutil unmount disk2s1

diskutil unmountDisk <disk> — Unmount all volumes on a disk.

diskutil unmountDisk disk2

diskutil unmount force <disk> — Force unmount a volume.

diskutil unmount force disk2s1

diskutil eject <disk> — Eject a disk (unmount and remove from system).

diskutil eject disk2

Format & Erase

Warning – irreversible data loss: eraseDisk, eraseVolume, partitionDisk and reformat destroy data permanently (complete data loss!). Always double-check the target diskN with diskutil list before running them – a wrong identifier will format the wrong drive.

diskutil eraseDisk <format> <name> <disk> — Erase an entire disk and create a single partition.

diskutil eraseDisk APFS MyDisk disk2

diskutil eraseVolume <format> <name> <disk> — Erase a single volume/partition.

diskutil eraseVolume APFS Data disk2s1

diskutil eraseDisk ExFAT USBDrive MBRFormat <disk> — Format a USB drive as ExFAT with MBR (cross-platform).

diskutil eraseDisk ExFAT USBDrive MBRFormat disk2

diskutil eraseDisk JHFS+ TimeMachine GPT <disk> — Format as HFS+ with GPT (for Time Machine).

diskutil eraseDisk JHFS+ TimeMachine GPT disk2

diskutil secureErase freespace 1 <disk> — Securely erase free space (1-pass zeros).

diskutil secureErase freespace 1 /Volumes/Macintosh\ HD

APFS Operations

diskutil apfs list — List all APFS containers and volumes.

diskutil apfs list

diskutil apfs addVolume <container> APFS <name> — Add a new volume to an APFS container.

diskutil apfs addVolume disk1 APFS Data

diskutil apfs deleteVolume <volume> — Delete an APFS volume.

diskutil apfs deleteVolume disk1s3

diskutil apfs resizeContainer <container> <size> — Resize an APFS container.

diskutil apfs resizeContainer disk1 200G

diskutil apfs listSnapshots <volume> — List APFS snapshots on a volume.

diskutil apfs listSnapshots disk1s1

diskutil apfs deleteSnapshot <volume> -name <name> — Delete a specific APFS snapshot.

diskutil apfs deleteSnapshot disk1s1 -name com.apple.TimeMachine.2026-03-19

Verify & Repair

diskutil verifyDisk <disk> — Verify the partition map of a disk.

diskutil verifyDisk disk0

diskutil verifyVolume <disk> — Verify the filesystem on a volume.

diskutil verifyVolume disk1s1

diskutil repairDisk <disk> — Repair the partition map of a disk.

sudo diskutil repairDisk disk0

diskutil repairVolume <disk> — Repair the filesystem on a volume.

sudo diskutil repairVolume disk1s1

Partitions

diskutil partitionDisk <disk> <n> GPT <format1> <name1> <size1> <format2> <name2> <size2> — Partition a disk with multiple partitions.

diskutil partitionDisk disk2 2 GPT APFS Data 100G ExFAT Shared R

diskutil addPartition <disk> <format> <name> <size> — Add a partition to a disk.

diskutil addPartition disk2 ExFAT Extra 50G

diskutil splitPartition <disk> <n> <format1> <name1> <size1> — Split an existing partition.

diskutil splitPartition disk2s2 2 APFS Part1 50G ExFAT Part2 R

diskutil mergePartitions <format> <name> <first> <last> — Merge adjacent partitions.

diskutil mergePartitions APFS Merged disk2s2 disk2s3

Conclusion

diskutil covers virtually everything the graphical Disk Utility can do – only faster, scriptable and usable over SSH. For everyday work, list, info, mount and unmount are all you need; the destructive verbs like eraseDisk, partitionDisk and reformat run without a confirmation prompt and without a trash – a single wrong diskN identifier can wipe an entire drive beyond recovery. Always identify the target with diskutil list first and check it a second time before you hit Enter.

Further Reading

  • caffeinate – prevent the Mac from going to sleep
  • defaults – read and write macOS preferences
  • dscl – Directory Service command line for users and groups