cheat sheet
diskutil
Command-line front-end to Disk Utility on macOS — list, partition, format, repair, encrypt, and snapshot APFS containers, plus build and tear down software RAID volumes.
diskutil — macOS Disk & APFS Management
What it is
diskutil is the macOS command-line front-end to Disk Utility, shipped by Apple in every release of macOS since Tiger (10.4). It manages every layer of the storage stack: physical disks (/dev/disk0), GPT partitions, APFS containers and volumes (synthesized at /dev/disk3, /dev/disk4, …), legacy CoreStorage and HFS+ volumes, software RAID sets, encryption (FileVault and per-volume APFS), and recovery operations like verifyVolume and repairVolume. It supersedes the older fdisk, pdisk, newfs_*, and hdiutil family for everyday disk administration, though hdiutil is still the tool for creating disk images (.dmg, sparse bundles). The Windows analogue is diskpart; on Linux the equivalent surface is split across lsblk, parted, mkfs.*, cryptsetup, and mdadm.
Install
diskutil ships with macOS at /usr/sbin/diskutil — there is nothing to install. Most read-only subcommands (list, info, apfs list) work without privilege; destructive operations (eraseDisk, resizeVolume, apfs deleteContainer) require either sudo or that the target volume is currently unmounted.
which diskutil
diskutil --version 2>/dev/null || diskutil | head -1
Output:
/usr/sbin/diskutil
Disk Utility Tool
Syntax
diskutil is a verb-first command: a top-level verb (list, info, mount, eraseDisk, apfs, ap, cs, appleRAID) plus its own arguments. The apfs and cs subcommands open their own verb namespace (e.g. diskutil apfs addVolume). Disk identifiers can be passed as disk2, /dev/disk2, a mountpoint (/), a volume name ("Macintosh HD"), or a UUID.
diskutil <verb> [<verb-args>...]
diskutil <namespace> <verb> [<verb-args>...]
# Examples of identifier forms
diskutil info disk0
diskutil info /
diskutil info "Macintosh HD"
diskutil info /Volumes/Backup
Output: (none — exits 0 on success)
Essential verbs
| Verb | Meaning |
|---|---|
list [-plist] [DEV] | Show all disks (or one device) and their partitions/volumes |
info [-plist] DEV | Detailed info for one device or volume |
mount DEV / unmount DEV | Mount or unmount a single volume |
unmountDisk [force] DEV | Unmount every volume on a whole disk |
eject DEV | Eject removable media |
eraseDisk FS NAME [GPT|MBR|APM] DEV | Reformat an entire disk |
eraseVolume FS NAME DEV | Reformat a single volume |
partitionDisk DEV NUMPARTS SCHEME (FS NAME SIZE)... | Rebuild partition map |
resizeVolume DEV SIZE [FS NAME SIZE]... | Grow/shrink a volume |
verifyVolume DEV / repairVolume DEV | First-aid checks |
verifyDisk DEV / repairDisk DEV | Whole-disk first aid |
secureErase LEVEL DEV | Multi-pass overwrite (HDD only; not for SSDs) |
apfs <verb> | APFS-specific subcommands (see below) |
image <verb> | Create/convert disk images (incl. ASIF on macOS 26 Tahoe) |
appleRAID <verb> | Software-RAID subcommands |
cs <verb> | Legacy CoreStorage subcommands |
enableJournal DEV / disableJournal DEV | HFS+ journaling |
mountDisk DEV | Mount every volume on a disk |
activity | Streaming log of disk arrival/removal/mount events |
Listing disks and volumes
diskutil list is the canonical inventory command: it walks every physical and synthesized device and prints a tree of partitions and APFS volumes. On Apple Silicon and recent Intel Macs the boot drive shows two synthesized containers — one for the sealed System volume and one for Data — because the root filesystem is split across an immutable signed snapshot and a writable Data volume.
diskutil list
Output:
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *994.7 GB disk0
1: Apple_APFS_ISC Container disk1 524.3 MB disk0s1
2: Apple_APFS Container disk3 988.8 GB disk0s2
3: Apple_APFS_Recovery Container disk2 5.4 GB disk0s3
/dev/disk3 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +988.8 GB disk3
Physical Store disk0s2
1: APFS Volume Macintosh HD 10.2 GB disk3s1
2: APFS Snapshot com.apple.os.update-... 10.2 GB disk3s1s1
3: APFS Volume Preboot 7.4 GB disk3s2
4: APFS Volume Recovery 1.0 GB disk3s3
5: APFS Volume Data 412.0 GB disk3s5
6: APFS Volume VM 20.5 KB disk3s6
Restricting list to a single device, requesting machine-readable plist output, and asking for an external-only listing are all routine variants — the plist form is what other tools parse.
diskutil list external # external/removable disks only
diskutil list internal # internal disks only
diskutil list physical # skip synthesized containers
diskutil list disk0 # one device
diskutil list -plist | plutil -convert json -o - -
Output: (truncated JSON)
{
"AllDisks": ["disk0","disk0s1","disk0s2","disk0s3","disk3","disk3s1","disk3s1s1","disk3s2","disk3s3","disk3s5","disk3s6"],
"AllDisksAndPartitions": [
{
"Content": "GUID_partition_scheme",
"DeviceIdentifier": "disk0",
"Partitions": [
{"DeviceIdentifier":"disk0s1","Content":"Apple_APFS_ISC","Size":524288000}
]
}
]
}
Detailed info
diskutil info is the deep-dive companion to list — it dumps every property the kernel knows about a single disk, slice, or volume, including device node, media name, SMART status, filesystem personality, mount point, owners-enabled flag, file vault state, and the UUIDs needed for fstab entries and snapshot references.
diskutil info / # info for the booted root
diskutil info disk0 # whole physical disk
diskutil info disk3s5 # APFS Data volume
Output (diskutil info disk0 — truncated):
Device Identifier: disk0
Device Node: /dev/disk0
Whole: Yes
Part of Whole: disk0
Device / Media Name: APPLE SSD AP1024Z
Volume Name: Not applicable (no file system)
Mounted: Not applicable (no file system)
Disk Size: 994.7 GB (994662584320 Bytes) (exactly 1942700360 512-Byte-Units)
Device Block Size: 4096 Bytes
Media Type: Generic
Protocol: Apple Fabric
SMART Status: Verified
Device Location: Internal
Removable Media: Fixed
Solid State: Yes
Virtual: No
Pipe info -plist into plutil -extract to read one property as a script value:
diskutil info -plist disk3s5 | plutil -extract VolumeUUID raw -o - -
Output:
4D7F1A8C-2B40-4F7B-9E12-1A2B3C4D5E6F
APFS containers and volumes
APFS (Apple File System) replaced HFS+ as the default filesystem in macOS 10.13 High Sierra. A physical partition (an "APFS Container") hosts one or more APFS volumes that all share the same free space pool — adding a volume does not require resizing. Volume roles (System, Data, Preboot, Recovery, VM, Update) and snapshots (immutable point-in-time clones) are core APFS concepts; the system boots from a signed snapshot of the System role for tamper-evidence.
diskutil apfs list # all containers and their volumes
diskutil apfs list disk3 # one container
diskutil apfs listSnapshots / # snapshots of the booted volume
Output (diskutil apfs list — abridged):
APFS Container (1 found)
|
+-- Container disk3 6F2B...
====================================================
APFS Container Reference: disk3
Size (Capacity Ceiling): 988800487424 B (988.8 GB)
Capacity In Use By Volumes: 431118245888 B (431.1 GB) (43.6% used)
Capacity Not Allocated: 557682241536 B (557.7 GB) (56.4% free)
|
+-< Physical Store disk0s2 A8...
|
+-> Volume disk3s1 — Macintosh HD (Role: System)
+-> Volume disk3s2 — Preboot (Role: Preboot)
+-> Volume disk3s3 — Recovery (Role: Recovery)
+-> Volume disk3s5 — Macintosh HD - Data (Role: Data)
+-> Volume disk3s6 — VM (Role: VM)
Adding and removing APFS volumes
addVolume carves a new volume out of the container's free pool — no resize is needed and the operation is online. The -quota and -reserve options are how you cap a volume's growth or guarantee minimum space; without them every volume can grow to fill the container.
# Add a 0-quota Scratch volume to the existing container
diskutil apfs addVolume disk3 APFS Scratch
# Add a volume with a hard cap of 50 GB
diskutil apfs addVolume disk3 APFS Builds -quota 50g
# Delete a volume by name or identifier
diskutil apfs deleteVolume Scratch
Output:
Will export new APFS Volume "Scratch" from APFS Container disk3
Started APFS operation on disk3
Preparing to add APFS Volume to APFS Container disk3
Creating APFS Volume
Mounting APFS Volume
Setting volume permissions
Disk from APFS operation: disk3s7
Finished APFS operation on disk3
Snapshots
APFS snapshots are read-only clones of a volume's metadata tree at a moment in time — they take essentially no space until the live volume diverges. Time Machine creates one before every backup; tmutil exposes a higher-level API but diskutil apfs is the low-level interface.
diskutil apfs listSnapshots / # list root snapshots
diskutil apfs createSnapshot / -name pre-upgrade # take one
diskutil apfs deleteSnapshot / -name pre-upgrade # delete by name
diskutil apfs deleteSnapshot / -uuid 4D7F1A8C-... # delete by UUID
Output (listSnapshots /):
Snapshots for disk3s1s1 (5 found)
+-- A1B2C3D4-1111-2222-3333-444455556666
| Name: com.apple.os.update-7F2A...
| XID: 812345
| Purgeable: No
+-- B2C3D4E5-2222-3333-4444-555566667777
| Name: pre-upgrade
| XID: 812400
| Purgeable: Yes
Container resize and rebalance
You can grow a container into adjacent free space or move space between APFS containers and a sibling HFS+/MS-DOS partition using apfs resizeContainer. The disk's GPT partition map is rewritten online when possible.
# Grow disk3 (the APFS container at disk0s2) to fill all free space on disk0
diskutil apfs resizeContainer disk0s2 0
# Shrink the container to 800 GB and create a 188.8 GB MS-DOS partition after it
diskutil apfs resizeContainer disk0s2 800g MS-DOS WORK 188.8g
Output:
Started APFS operation
Aligning grow delta to 188,803,883,008 bytes and targeting a new physical store size of 800,000,000,000 bytes
Determined the maximum size for the targeted physical store of this APFS Container to be 988,795,719,680 bytes
Resizing APFS Physical Store from 988,800,487,424 to 800,000,000,000 bytes
Modifying partition map
Initialized /dev/rdisk0s3 as a 175 GB case-insensitive MS-DOS (FAT32) volume
Mounting disk
Finished APFS operation
Partitioning a fresh disk
partitionDisk lets you wipe a disk's partition map and rebuild it in one atomic operation. Pass the device, the number of partitions, the scheme (GPT for modern Macs, MBR for compatibility with BIOS PCs, APM only for very old PowerPC Macs), and a FS NAME SIZE triple for each partition. A size of 0 or R means "rest of disk".
# Single APFS partition spanning the whole disk
sudo diskutil partitionDisk /dev/disk4 1 GPT APFS "External" 0
# Two partitions: 200 GB APFS + remainder ExFAT (for cross-platform use)
sudo diskutil partitionDisk /dev/disk4 2 GPT \
APFS "Mac" 200g \
ExFAT "Shared" 0
Output:
Started partitioning on disk4
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk4s2 as APFS with name Mac
Initialized /dev/rdisk4s2 as a 200 GB APFS Container
Formatting disk4s3 as ExFAT (Extended Allocation Table) with name Shared
mkexfatfs 1.3.0
Creating... done.
Flushing... done.
File system created successfully.
Mounting disk
Finished partitioning on disk4
Erasing a disk or volume
eraseDisk reformats an entire device (partition map + filesystem); eraseVolume only reformats one slice. The filesystem keyword is what newfs_* understands: APFS, APFSX (case-sensitive), JHFS+ (journaled HFS+), JHFS+X (case-sensitive journaled), ExFAT, MS-DOS FAT32, Free Space. Erasing the booted volume is not allowed — boot from Recovery first.
# Erase /dev/disk4 to APFS, single volume named "Photos"
sudo diskutil eraseDisk APFS "Photos" /dev/disk4
# Erase to exFAT for Windows interoperability
sudo diskutil eraseDisk ExFAT "USB" MBR /dev/disk4
# Reformat just disk4s2 without touching the partition map
sudo diskutil eraseVolume APFS "Scratch" /dev/disk4s2
Output:
Started erase on disk4
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk4s2 as APFS with name Photos
Initialized /dev/rdisk4s2 as a 119 GB APFS Container
Mounting disk
Finished erase on disk4
Encryption and FileVault
APFS supports per-volume hardware-accelerated encryption that is independent of FileVault on the boot drive. FileVault adds the user-keyed unlock and recovery-key flow for the system Data volume; diskutil apfs encryptVolume and the related -fileVault flag manage the lower-level conversion. The system volume's FileVault state is also surfaced by fdesetup status.
# Erase an external disk to encrypted APFS, prompting for a passphrase
sudo diskutil apfs eraseDisk APFS "Secure" /dev/disk4 \
-passphrase # prompt interactively
# Convert an existing unencrypted APFS volume to encrypted, in place
sudo diskutil apfs encryptVolume /Volumes/Photos \
-user disk -passphrase
# Check encryption progress / status
diskutil apfs list disk5 | grep -E "FileVault|Encryption"
# Decrypt an APFS volume (long, online operation)
sudo diskutil apfs decryptVolume /Volumes/Photos -passphrase
# Unlock an encrypted APFS volume that mounted without a key
diskutil apfs unlockVolume /Volumes/Secure -passphrase
# Lock (dismount + drop key) an unlocked volume
diskutil apfs lockVolume /Volumes/Secure
Output (status line):
FileVault: Yes (Encrypted at rest using AES-XTS)
Encryption Type: AES-XTS
Encryption Progress: 42.7%
FileVault on the boot drive is managed by fdesetup, not diskutil, but the two tools share the same APFS volume key chain:
sudo fdesetup status # FileVault state of boot drive
sudo fdesetup enable # turn FileVault on (will prompt)
sudo fdesetup list # users authorized to unlock
Output:
FileVault is On.
RAID with appleRAID
diskutil appleRAID builds software RAID sets — mirror (RAID 1), stripe (RAID 0), or concat (JBOD) — out of two or more disks. RAID-5 was removed in modern macOS; for parity raid you now reach for ZFS via OpenZFS, btrfs (Linux), or a hardware controller. The resulting RAID device shows up as a new /dev/diskN that you then erase to APFS or HFS+ like any other disk.
# Build a mirror (RAID 1) of two external disks
sudo diskutil appleRAID create mirror "MirrorSet" APFS \
/dev/disk5 /dev/disk6
# Build a stripe (RAID 0) for throughput
sudo diskutil appleRAID create stripe "StripeSet" APFS \
/dev/disk5 /dev/disk6
# Show all RAID sets
diskutil appleRAID list
# Add a spare to an existing set
sudo diskutil appleRAID add spare <setUUID> /dev/disk7
# Tear down a set (does not erase member disks unless you ask)
sudo diskutil appleRAID delete <setUUID>
Output (appleRAID list):
AppleRAID sets (1 found)
===============================================================================
Name: MirrorSet
Unique ID: 7F3A1C2D-4B5E-6789-ABCD-EF0123456789
Type: Mirror
Status: Online
Size: 999.0 GB (999000000000 Bytes)
Rebuild: manual
Device Node: disk7
-------------------------------------------------------------------------------
# DevNode UUID Status Size
0 disk5s2 A1B2C3D4-... Online 999.0 GB
1 disk6s2 B2C3D4E5-... Online 999.0 GB
First aid: verify and repair
verifyVolume runs fsck_* against a volume read-only; repairVolume runs it read-write and fixes what it can. verifyDisk/repairDisk operate on the partition map. You cannot repair the booted system volume because it is mounted read-only as a sealed snapshot — boot from Recovery (⌘R) and run from there for system-volume repairs.
diskutil verifyVolume / # read-only check of booted volume
sudo diskutil verifyVolume disk4s2 # check external APFS volume
sudo diskutil repairVolume disk4s2 # attempt repairs
sudo diskutil verifyDisk disk4 # check partition map
sudo diskutil repairDisk disk4 # repair partition map
Output (verifyVolume):
Started file system verification on disk4s2 USB
Verifying file system
Performing fsck_apfs -n -x /dev/rdisk4s2
Checking the container superblock
Checking the EFI jumpstart record
Checking the space manager
Checking the object map
Checking the snapshot metadata tree
Checking the snapshot metadata
Checking volume
Checking the object map
Checking the fsroot tree
Checking the extent ref tree
Verifying allocated space
The volume /dev/rdisk4s2 appears to be OK.
Finished file system verification on disk4s2 USB
Secure erase
secureErase overwrites the device with one or more passes of zeros/random data. It is intended only for spinning hard disks — modern SSDs (every Apple-Silicon Mac, every recent Intel Mac) implement wear-levelling and over-provisioning that make a multi-pass overwrite both useless and harmful (wears the flash). For SSDs, the right approach is whole-disk APFS encryption from day one, then diskutil eraseDisk to destroy the key.
# Level 0 = single-pass zero, 1 = US DoE, 2 = 7-pass DoD, 3 = 35-pass Gutmann
sudo diskutil secureErase 0 /dev/disk4 # spinning disk only
sudo diskutil secureErase freespace 0 / # zero only the free space (any disk)
Output:
Started erase on disk4
0%..10%..20%..30%..40%..50%..60%..70%..80%..90%..100%
Finished erase on disk4
Live disk events
diskutil activity streams disk arrival, departure, and mount events in real time — handy when you are debugging an external dock, troubleshooting why a USB stick disappears, or scripting an auto-mount workflow.
diskutil activity
Output:
***DiskAppeared ('disk4', DAVolumePath = '', DAVolumeKind = '', DAVolumeName = '')
***DiskAppeared ('disk4s1', DAVolumePath = '', DAVolumeKind = 'msdos', DAVolumeName = 'EFI')
***DiskAppeared ('disk4s2', DAVolumePath = '', DAVolumeKind = 'apfs', DAVolumeName = '')
***DiskAppeared ('disk5', DAVolumePath = '', DAVolumeKind = 'apfs', DAVolumeName = 'USB')
***DiskMountApproval ('disk5', id = 0xXXXX) Approving
***DiskDescriptionChanged ('disk5', DAVolumePath = 'file:///Volumes/USB/')
^C
diskutil vs other tools
The classic Unix disk tools still exist on macOS but each is now a narrower slice of what diskutil covers.
| Tool | What it does | When to prefer over diskutil |
|---|---|---|
diskutil | Disks, partitions, APFS, RAID, FileVault, repair | The default for everything |
fdisk | MBR partition tables on raw block devices | Almost never — only for legacy BIOS targets |
gpt | GPT partition tables only | Scripting low-level GPT entries the Apple way won't do |
newfs_apfs, newfs_hfs, newfs_exfat, newfs_msdos | Filesystem creation primitives | Already invoked under the hood by eraseDisk |
hdiutil | Create, mount, attach, convert disk images (.dmg, .sparsebundle, .iso) | Always for disk images — diskutil does not touch them |
fsck_apfs / fsck_hfs | Filesystem integrity check primitives | Already invoked by repairVolume; call directly when you need -y or -l flags |
mount / umount | Generic POSIX mount syscalls | When you need non-standard mount options (noowners, nodev) |
mount_apfs, mount_smbfs, mount_nfs | Per-filesystem mount helpers | When mounting a snapshot or network share |
dd | Raw block copy | Cloning bit-for-bit images outside the APFS model |
asr | Apple Software Restore (block/file-level imaging) | Cloning a bootable APFS volume from a snapshot to another disk |
Common pitfalls
- Erasing the booted volume fails by design — you cannot reformat
/while it is mounted. Boot from Recovery (⌘Ron Intel, hold the power button on Apple Silicon) or another disk first. secureEraseon an SSD wears the flash and does not actually overwrite cells — wear-levelling routes writes elsewhere. Use whole-disk encryption from day one and destroy the key witheraseDiskinstead.apfs deleteContaineris destructive but does not require--force— every volume inside the container vanishes immediately. Always re-readdiskutil listand have a backup before pulling the trigger.- Mounting a snapshot is read-only and requires the parent volume's mount point —
mount_apfs -s <snapshot-name> /System/Volumes/Data /mntis the form; you cannotdiskutil mounta snapshot directly. - External Time Machine APFS disks created by macOS contain a hidden "Backups" volume —
eraseDiskfrom the GUI sometimes leaves the role volume behind; useeraseDiskfrom the command line on the parent/dev/diskNto get a clean slate. diskutilaccepts a mountpoint as a disk identifier —diskutil unmount /Volumes/USBworks, but if the mountpoint name contains spaces you must quote it. Prefer the device identifier in scripts.- Resizing an APFS container into an adjacent HFS+ partition refuses if the HFS+ slice has data —
resizeContaineronly consumes free space or destroys partitions it is told to via the trailingFS NAME SIZEtriple. diskutil apfs encryptVolumeruns in the background — the command returns instantly.diskutil apfs listshowsEncryption Progress: NN%while it converts. Do not eject the disk.Apple_APFS_ISCandApple_APFS_Recoverypartitions are critical on Apple Silicon Macs — touchingdisk0s1ordisk0s3witheraseDiskorpartitionDiskwill brick the machine. Always confirm the target identifier before destructive verbs.enableJournal/disableJournalis HFS+ only — APFS has no on-disk journal in the HFS+ sense; the equivalent is APFS's copy-on-write metadata. Don't try to disable journaling for "performance" on APFS.
Real-world recipes
Format a fresh external drive as encrypted APFS
A common one-step setup for a new USB-C SSD: wipe it, write a GPT partition map, create an encrypted APFS container with a single volume named Backup, and mount it.
# 1. Identify the new disk (look at "external, physical")
diskutil list external
# 2. Erase to encrypted APFS — passphrase prompt is interactive
sudo diskutil apfs eraseDisk APFS Backup /dev/disk5 -passphrase
# 3. Verify
diskutil apfs list | grep -E "Container|Volume"
Output:
Started APFS operation on disk5
Unmounting Volumes
Erasing
...
Finished APFS operation on disk5
+-- Container disk6 7F2A...
+-> Volume disk6s1 — Backup (Role: No specific role)
Snapshot-backed rollback before a system upgrade
Take a named APFS snapshot before installing a new tool, run the change, and mount the snapshot read-only to diff against if something breaks.
# 1. Pre-snapshot
sudo diskutil apfs createSnapshot / -name pre-brew-upgrade
# 2. Make the risky change
brew upgrade
# 3. Mount the snapshot read-only at /mnt/snap to compare
sudo mkdir -p /mnt/snap
sudo mount_apfs -s pre-brew-upgrade /System/Volumes/Data /mnt/snap
# 4. Diff a directory
diff -r /mnt/snap/usr/local /usr/local | head -20
# 5. Done — unmount and (optionally) delete the snapshot
sudo umount /mnt/snap
sudo diskutil apfs deleteSnapshot / -name pre-brew-upgrade
Output:
Started APFS operation on disk3s1
Snapshotting APFS Volume "Macintosh HD" and storing the snapshot with name "pre-brew-upgrade"
Created snapshot with XID 812400
Finished APFS operation on disk3s1
Build a striped scratch volume on two USB SSDs
For temporary high-throughput work (video transcodes, build artefacts), stripe two external SSDs into a single throwaway volume.
# Wipe both disks first so they have no live data
sudo diskutil unmountDisk force /dev/disk5
sudo diskutil unmountDisk force /dev/disk6
# Stripe + APFS
sudo diskutil appleRAID create stripe Scratch APFS /dev/disk5 /dev/disk6
# Confirm
diskutil list | grep -A2 "Scratch"
Output:
Started RAID operation on disk5
Unmounting disk5
Repartitioning disk5
...
Finished RAID operation
/dev/disk8 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
1: APFS Volume Scratch 998.0 GB disk8s1
Create an ASIF disk image (macOS 26 Tahoe)
ASIF is a new sparse disk image format introduced in macOS 26 Tahoe that achieves near-native read/write speeds (multi-GB/s on Apple Silicon) and stores efficiently regardless of the host filesystem. Unlike UDSP sparse-bundle or UDIF images created with hdiutil, ASIF images are made through diskutil image create. They are the recommended format for VM disks and developer scratch images on Tahoe and later, and are not back-portable to Sequoia or earlier.
# Create a 100 GB blank ASIF image with a single APFS volume named "VM"
diskutil image create blank --format ASIF --size 100G \
--volumeName VM ~/Images/dev-vm.asif
# Convert an existing image to ASIF
diskutil image create from ~/Images/old.dmg --format ASIF \
~/Images/converted.asif
# Attach and detach like any other disk image
hdiutil attach ~/Images/dev-vm.asif
hdiutil detach /dev/disk7
Output:
Started image operation
Creating ASIF image
Initialized /dev/rdiskN as a 100 GB APFS Container
Created /Users/alice/Images/dev-vm.asif
Finished image operation
ASIF is currently only available in Tahoe's Disk Utility and via diskutil image; older releases still need hdiutil create -format UDSP (or UDRW) for sparse images.
One-shot script: clone a USB stick to an APFS image
Use hdiutil (the disk-image cousin of diskutil) to read a USB stick into a sparse .dmg, then mount it back on demand. diskutil itself does not make images — but the pair is a natural pipeline.
# 1. Find source
diskutil list external
# 2. Create a read-only sparse image
sudo hdiutil create -srcdevice /dev/disk5 \
-format UDSP \
-o ~/Backups/usb-stick.sparseimage
# 3. Later: attach for read-only inspection
hdiutil attach -readonly ~/Backups/usb-stick.sparseimage
# 4. Unmount when done
hdiutil detach /dev/disk7
Output:
Reading Protective Master Boot Record (MBR : 0)…
Reading GPT Header (Primary GPT Header : 1)…
...
created: /Users/alice/Backups/usb-stick.sparseimage
Find which disk a path lives on
Map an arbitrary path back to its /dev/diskN identifier — useful when piping into other tools that take device nodes.
df -h /Users/alice/Movies | awk 'NR==2{print $1}'
diskutil info /Users/alice/Movies | awk -F': +' '/Device Node/{print $2}'
Output:
/dev/disk3s5
/dev/disk3s5
Repair a flaky external drive end-to-end
When an external disk starts throwing I/O errors, the canonical sequence is: unmount → verifyDisk → repairDisk → verifyVolume per slice → repairVolume per slice. If repair fails, restore from backup and re-format.
sudo diskutil unmountDisk force /dev/disk4
sudo diskutil verifyDisk disk4
sudo diskutil repairDisk disk4
sudo diskutil verifyVolume disk4s2
sudo diskutil repairVolume disk4s2
diskutil mountDisk disk4
Output:
Started partition map verification on disk4
Verifying the partition list
Verifying the partition map size
Checking prerequisites
Checking the partition list
Checking the partition map
The partition map appears to be OK.
Finished partition map verification on disk4
Free up disk by purging Time Machine local snapshots
When your boot drive shows "Purgeable" space you can't recover, the culprit is usually local Time Machine snapshots. diskutil lists them; tmutil deletes them.
# List
diskutil apfs listSnapshots / | grep -E "Name:|XID:"
# Delete every local TM snapshot older than today (handled by tmutil)
for s in $(tmutil listlocalsnapshotdates / | tail -n +2); do
sudo tmutil deletelocalsnapshots "$s"
done
# Confirm
diskutil apfs listSnapshots / | grep -c "Name:"
Output:
Name: com.apple.TimeMachine.2026-05-23-093011.local
XID: 812345
Name: com.apple.TimeMachine.2026-05-24-092805.local
XID: 812900
Deleted: 2026-05-23-093011
Deleted: 2026-05-24-092805
0
Sources
- Apple — File system formats in Disk Utility — official list of formats Disk Utility /
diskutilcan create on each macOS release. - Eclectic Light — macOS Tahoe brings a new disk image format (ASIF) — deep-dive on the ASIF format, performance numbers, and the
diskutil image createsyntax. - Eclectic Light — Local file systems supported by macOS 26 — survey of APFS variants, HFS+, and ExFAT support in Tahoe.
- Apple — macOS Tahoe 26 release notes — official changelog for the current macOS release.