To erase a disk from the Mac command line, use the built-in diskutil utility: identify the correct disk with diskutil list, then erase it with diskutil eraseDisk. Erasing permanently removes data from the selected volume or disk, so verify the device identifier and make a backup before running any erase command.
What the erase command does
diskutil is macOS’s command-line tool for managing disks, partitions, and volumes. Its eraseDisk operation repartitions a whole disk and creates a new volume using the filesystem and name you specify. It is different from eraseVolume, which targets a volume rather than rebuilding the entire disk.
A typical command has this form:
diskutil eraseDisk FORMAT NAME IDENTIFIER
For example, to erase an external disk identified as disk4 and create an APFS volume named Work, the command is:
diskutil eraseDisk APFS Work disk4
This example is only safe if disk4 is actually the intended disk on your Mac. Disk numbers can change when you connect or disconnect devices, so never copy an identifier from an example without checking it on your own system.
Identify the disk before erasing
Open Terminal, then list available disks and their volumes:
diskutil list
Look for the disk’s identifier, capacity, partition layout, and volume names. Compare the displayed capacity with the physical device you mean to erase. An external drive may appear as /dev/disk4, with its partitions shown as disk4s1 and disk4s2. The whole-disk command generally uses the parent identifier, such as disk4, not one of its partition identifiers.
For more detail about a particular disk, run:
diskutil info /dev/disk4
Replace disk4 with the identifier you found. Check the device description, size, and whether it is internal or external. If you are uncertain, stop rather than guessing. Erasing the wrong disk can destroy files, and macOS may not provide a way to recover them.
Choose a format and partition scheme
The format determines how the new volume stores files and which devices can read it. The right choice depends on how you will use the disk:
- APFS: A common choice for modern Macs, especially for SSDs and Mac-only use. Some older macOS systems and non-Apple devices may not support it.
- Mac OS Extended (Journaled): Also called HFS+. It can be useful when compatibility with older Mac systems is required, but it is not the usual choice for a new disk intended only for current Macs.
- ExFAT: Often chosen for exchanging files between Macs and Windows PCs. It does not provide all the features of a Mac-specific filesystem.
- MS-DOS (FAT): A compatibility option for some devices, but it has file-size and other limitations. Confirm the needs of the device that will use the disk.
For example, an external SSD used only with current Macs might be erased as APFS, while a drive that must move files between macOS and Windows is often formatted as ExFAT. These are examples, not universal recommendations; check the requirements of any camera, console, recorder, or other device that will use the drive.
The partition scheme is separate from the filesystem. To specify GUID Partition Map explicitly, use the -scheme option:
diskutil eraseDisk APFS Work GPT /dev/disk4
Here, GPT requests a GUID Partition Map. A whole-disk erase creates a new partition layout as well as a volume. If you need a particular layout or multiple partitions, use Disk Utility or consult the diskutil manual rather than assuming this single-volume command will create it.
Erase a disk step by step
- Copy any files you need elsewhere and confirm that the backup is accessible. An erase is destructive.
- Connect the intended external drive, if applicable, and run
diskutil list. - Verify the disk identifier and capacity. If useful, inspect it with
diskutil info /dev/diskN, substituting the actual identifier. - Choose a supported filesystem and a volume name. Avoid spaces in the name for a simpler command, or quote a name that contains spaces.
- Run the command with the correct whole-disk identifier. For example:
diskutil eraseDisk ExFAT Shared GPT /dev/disk4. - Read Terminal’s output and wait for the operation to finish. Then run
diskutil listagain to confirm the resulting volume and format.
Use the device identifier exactly as shown by your Mac. Do not assume the disk number remains the same after restarting, reconnecting a drive, or attaching another storage device.
Erasing the startup disk
The disk currently running macOS usually cannot be erased normally from the same installed system. To erase a Mac’s startup storage, start the Mac in macOS Recovery, open Disk Utility, and use its erase controls. The exact startup procedure varies by Mac model; Apple’s current instructions explain how to enter Recovery for the machine in question.
In Disk Utility, choose View > Show All Devices when you need to see the physical device and its containers or volumes. Select the appropriate item carefully: erasing a volume is not always the same as erasing the physical device. If the goal is to reinstall macOS, follow the installation steps for Recovery after erasing. Do not try to force an erase of an in-use startup disk with Terminal commands.
Common problems and data safety
If a command fails, first check the identifier, spelling, and format name. The disk may be in use, disconnected, read-only, or affected by a cable or hardware problem. For an external drive, reconnect it directly if possible, then rerun diskutil list; do not reuse an old identifier without checking.
Some operations require administrator privileges. If macOS reports that permission is denied, consult the command’s help or manual before considering sudo. Adding administrator privileges does not make an incorrect target safe, and it will not fix every cause of failure.
Also distinguish ordinary erasing from secure data destruction. Reformatting removes the existing filesystem layout, but it is not a guarantee that every prior bit of data is unrecoverable. On SSDs and other flash storage, wear-leveling and device behavior make traditional overwrite assumptions unreliable. If the disk held sensitive information and must be disposed of, use a suitable device-supported sanitization process or seek qualified help; do not assume a normal erase is a secure wipe.
Frequently Asked Questions
What command lists disks on a Mac?
Run diskutil list in Terminal. It displays disks, partitions, volumes, and their identifiers.
How do I erase a Mac disk using Terminal?
After verifying the whole-disk identifier, use diskutil eraseDisk FORMAT NAME IDENTIFIER. For example, diskutil eraseDisk APFS Work disk4 erases disk4 and creates an APFS volume named Work.
Does eraseDisk erase the whole drive?
It targets the whole disk and rebuilds its partition layout. Use the correct parent disk identifier, not a partition identifier, and remember that all data on the target may be lost.
Can I erase the disk my Mac is using?
Usually not from the running macOS installation. Start in macOS Recovery and use Disk Utility to erase the startup storage when that is your goal.
Is formatting a disk the same as securely wiping it?
No. A normal erase is not a guarantee of secure, unrecoverable destruction, particularly for SSDs. Use an appropriate sanitization method if secure disposal is required.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Immortals Fenyx Rising Co-op, Crossplay and Friends
- AI Inference Near the Device: When It Makes Sense
- Restore Default Settings on a Sons of the Forest Server
- Best Music Streaming Service in India: How to Choose
- How to Clean Gaming Headset Ear Pads Safely
- First Light Trophy List and How to Earn Them