Skip to content

Instantly share code, notes, and snippets.

@startergo
Created November 27, 2020 14:00
Show Gist options
  • Save startergo/9449bcbc025f216a7184dde08d8ec2b0 to your computer and use it in GitHub Desktop.
Save startergo/9449bcbc025f216a7184dde08d8ec2b0 to your computer and use it in GitHub Desktop.
diskutil eraseVolume format
diskutil eraseVolume format name MountPoint|DiskIdentifier|DeviceNode
Erase a single disk partition or whole, laying down a new file system volume
that will be empty of files. Format is the specific file system personality
name of the new volume, e.g. "Journaled HFS+" or a common alias e.g. "jhfs+".
Name is the new volume name (subject to file system naming restrictions) or
can be specified as %noformat% to skip initialization (to skip newfs). You
cannot erase the boot volume. A pseudo-format of "free" or "Free Space" will
remove the partition altogether, leaving a free space gap in the partition map.
Ownership of the affected disk is required.
Examples: diskutil eraseVolume JHFS+ UntitledHFS /Volumes/SomeDisk
diskutil eraseVolume "Journaled HFS+" FooWholeVolEgRaid disk7
diskutil eraseVolume ms-dos FOO disk0s5
diskutil eraseVolume free free disk0s5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment