CLI powerhouse for inspecting & managing physical / virtual disks
diskutil is Apple’s Swiss-army knife for storage: listing, partitioning, reparing, erasing, APFS & RAID administration, CoreStorage control, image mounting, scripting and much more
Basic usage pattern:
diskutil verb [options] [targets…]
diskutil list
to discover the correct /dev/diskX identifier.info
, eraseDisk
, etc.).Enumerate & query metadata safely before touching data
diskutil list
Shows the system’s BSD names, containers, partitions, and file-systems
diskutil info /dev/disk2s1
or
diskutil info -all
Tip: pipe through grep
or jq
when using -plist
for scripts.
Create, resize or wipe volumes (HFS+, APFS, ExFAT…)
diskutil eraseDisk APFS "My SSD" /dev/disk4
diskutil partitionDisk /dev/disk2 3 GPT APFS "Data" 100G MS-DOS "BOOT" 16G Free Space 0B
Level | Passes / Pattern |
---|---|
0 | Single-pass zeros (quick) |
1 | Single-pass random |
2 | US-DoD 3-pass |
3 | US-DoD 7-pass |
4 | 35-pass Gutmann |
diskutil secureErase 1 /dev/disk3
On SSDs, rely on FileVault + whole-disk erase; repeated overwrites are ineffective
Containers, volumes & snapshots in Apple’s modern FS
diskutil apfs list
diskutil apfs createContainer /dev/disk2s2
diskutil apfs addVolume disk2 APFS "Projects"
diskutil apfs resizeContainer disk2 0
⟶ expand to fill device.
diskutil apfs listsnapshots /
diskutil apfs deleteSnapshot disk2s5 -uuid UUID-HERE
Bring volumes online or take them safely offline
diskutil mountDisk /dev/disk3
— mounts every mount-able volume on the physical.
diskutil mount -readonly /dev/disk3s1
diskutil unmountDisk /dev/disk3
Always unmount before physical removal or imaging.
First-aid for file-system corruption
diskutil verifyDisk /dev/disk1
– checks partition map.
diskutil verifyVolume /dev/disk1s2
diskutil repairVolume /Volumes/Macintosh HD
On APFS, these call fsck_apfs in live-verify mode
Legacy tools still ship with diskutil
Create stripe:
diskutil appleRAID create stripe "Scratch RAID0" JHFS+ disk3 disk4
Convert CoreStorage into APFS:
diskutil coreStorage convert LVUUID
AppleRAID/CoreStorage are deprecated—prefer APFS volumes or H/W RAID.
Use -plist, JSON & exit status for robust scripts
diskutil info -plist disk2s1 | plutil -convert json -o - - -
$?
to branch on success / failure.bash -euo pipefail
.Apple Configurator & MDM workflows may call diskutil under the hood.
Quick copy-paste for everyday ops
Goal | Command |
---|---|
Clone bootable USB | sudo asr --source /dev/disk4 --target /dev/disk5 --erase |
Enable journaling (HFS+) | diskutil enableJournal /Volumes/ARCHIVE |
Rename volume | diskutil rename /Volumes/OLD NewName |
Eject all externals | diskutil external | xargs -I{} diskutil unmountDisk {} |
Avoid data loss; maximise success rates
diskutil list
; confirm target identifiers twice.Man-pages & Apple technical notes
diskutil
man page via SS64