Commands · Command
CommandmacOS
diskutil
diskutil verb [options] [disk/volume identifier]macOS's command-line utility for inspecting, partitioning, formatting, mounting, and repairing disks and volumes — the CLI counterpart to the graphical Disk Utility app, and Apple's recommended tool over legacy Unix disk utilities.
// FLAGS
listshow every attached disk and its partitionsinfoshow detailed information about a specific disk or volumeeraseDiskerase and reformat an entire diskunmountDiskunmount every volume on a disk (needed before physically ejecting it)verifyDisk / repairDiskcheck or repair a disk's partition map and filesystem// EXAMPLE
diskutil list — lists every attached disk and its partitions with identifiers like /dev/disk2s1.
// GOTCHA
diskutil operates at either the whole-disk or single-partition identifier level (e.g. disk2 vs. disk2s1) — running a disk-level verb like eraseDisk against a partition identifier instead of the whole-disk identifier does something different than intended, and vice versa.
// RELATED COMMANDS