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 listdiskutil list internal — List only internal disks.
diskutil list internaldiskutil list external — List only external disks.
diskutil list externaldiskutil info <disk> — Show detailed info about a disk or partition.
diskutil info disk0s1diskutil info -all — Show info for all disks.
diskutil info -alldiskutil activity — Monitor disk activity in real-time.
diskutil activityMount & Unmount
diskutil mount <disk> — Mount a volume.
diskutil mount disk2s1diskutil mountDisk <disk> — Mount all volumes on a disk.
diskutil mountDisk disk2diskutil unmount <disk> — Unmount a volume.
diskutil unmount disk2s1diskutil unmountDisk <disk> — Unmount all volumes on a disk.
diskutil unmountDisk disk2diskutil unmount force <disk> — Force unmount a volume.
diskutil unmount force disk2s1diskutil eject <disk> — Eject a disk (unmount and remove from system).
diskutil eject disk2Format & Erase
Warning – irreversible data loss:
eraseDisk,eraseVolume,partitionDiskandreformatdestroy data permanently (complete data loss!). Always double-check the targetdiskNwithdiskutil listbefore 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 disk2diskutil eraseVolume <format> <name> <disk> — Erase a single volume/partition.
diskutil eraseVolume APFS Data disk2s1diskutil eraseDisk ExFAT USBDrive MBRFormat <disk> — Format a USB drive as ExFAT with MBR (cross-platform).
diskutil eraseDisk ExFAT USBDrive MBRFormat disk2diskutil eraseDisk JHFS+ TimeMachine GPT <disk> — Format as HFS+ with GPT (for Time Machine).
diskutil eraseDisk JHFS+ TimeMachine GPT disk2diskutil secureErase freespace 1 <disk> — Securely erase free space (1-pass zeros).
diskutil secureErase freespace 1 /Volumes/Macintosh\ HDAPFS Operations
diskutil apfs list — List all APFS containers and volumes.
diskutil apfs listdiskutil apfs addVolume <container> APFS <name> — Add a new volume to an APFS container.
diskutil apfs addVolume disk1 APFS Datadiskutil apfs deleteVolume <volume> — Delete an APFS volume.
diskutil apfs deleteVolume disk1s3diskutil apfs resizeContainer <container> <size> — Resize an APFS container.
diskutil apfs resizeContainer disk1 200Gdiskutil apfs listSnapshots <volume> — List APFS snapshots on a volume.
diskutil apfs listSnapshots disk1s1diskutil apfs deleteSnapshot <volume> -name <name> — Delete a specific APFS snapshot.
diskutil apfs deleteSnapshot disk1s1 -name com.apple.TimeMachine.2026-03-19Verify & Repair
diskutil verifyDisk <disk> — Verify the partition map of a disk.
diskutil verifyDisk disk0diskutil verifyVolume <disk> — Verify the filesystem on a volume.
diskutil verifyVolume disk1s1diskutil repairDisk <disk> — Repair the partition map of a disk.
sudo diskutil repairDisk disk0diskutil repairVolume <disk> — Repair the filesystem on a volume.
sudo diskutil repairVolume disk1s1Partitions
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 Rdiskutil addPartition <disk> <format> <name> <size> — Add a partition to a disk.
diskutil addPartition disk2 ExFAT Extra 50Gdiskutil splitPartition <disk> <n> <format1> <name1> <size1> — Split an existing partition.
diskutil splitPartition disk2s2 2 APFS Part1 50G ExFAT Part2 Rdiskutil 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
- diskutil(8) – man page – complete reference of all verbs and options
- Apple Support – Disk Utility – official documentation for the graphical counterpart
Related Commands
- caffeinate – prevent the Mac from going to sleep
- defaults – read and write macOS preferences
- dscl – Directory Service command line for users and groups