Disk Utility is usually enough to erase a drive, but sometimes it will not delete a stubborn partition: drives coming from Windows or Linux, bootable USB sticks, SD cards with several partitions or drives with a damaged partition scheme. In those cases diskutil from Terminal erases the whole drive and leaves a single clean partition.
This guide is for external or secondary drives. For the Mac’s internal disk there is a different procedure further down.
Before you start
- Back up. Everything you are about to do erases the whole drive and cannot be undone.
- Disconnect other external drives you will not touch. That reduces the risk of picking the wrong identifier.
- You need an administrator account.
Step 1: try Disk Utility first
- Open Disk Utility (Applications > Utilities).
- Go to View > Show All Devices. Without this you only see volumes and cannot delete partitions.
- Select the physical device (the top line with the manufacturer’s name).
- Click Erase, pick a format and the GUID Partition Map scheme.
If it errors or the scheme option does not appear, continue with Terminal.
Step 2: identify the right drive
Open Terminal and list the drives:

diskutil list
You will see entries like /dev/disk0 (internal), /dev/disk4 (external, physical) and so on. Find yours by size and the external, physical label. To be completely sure:
diskutil info disk4
Check the device name (Device / Media Name), the size and that it says external. The examples use disk4: replace it with yours.
Step 3: unmount the drive
diskutil unmountDisk disk4
If it says it is in use, close the apps with files open on it, or force the unmount:
diskutil unmountDisk force disk4
Step 4: erase all partitions
The most direct way is eraseDisk, which rewrites the partition scheme and creates a single volume:

diskutil eraseDisk APFS "MiDisco" GPT disk4
Choose the format according to use:
| Format | When to use it |
|---|---|
APFS | Mac only, SSD and NVMe. Recommended for current macOS |
JHFS+ | Mac OS Extended (Journaled): mechanical drives or old Macs |
ExFAT | Sharing with Windows and other devices |
FAT32 | Old devices (files up to 4 GB; better with the MBR scheme) |
The method from the original article using partitionDisk also still works. It creates one partition filling the whole drive (R means “the rest of the space”):
diskutil partitionDisk disk4 1 GPT APFS "MiDisco" R
If the drive will be used on a very old PC with BIOS, change GPT to MBR.
Erase the Mac’s internal disk
Do not use these commands on disk0 on an Apple silicon Mac. The internal disk holds system containers the Mac needs to boot; if you erase them, the Mac may be unable to start until you restore it from another Mac.
The right way is:
- To reset the Mac to factory state (Apple silicon or T2 chip Macs, macOS Monterey or later): System Settings > General > Transfer or Reset > Erase All Content and Settings. It erases all volumes and users and signs out of iCloud.
- To erase the disk from Recovery: start macOS Recovery (on Apple silicon, hold the power button and choose Options; on Intel Macs, Command (⌘)-R), open Disk Utility, select Macintosh HD and click Erase (or Erase Volume Group if shown). Then reinstall macOS from the same Recovery.
All key combinations are in macOS startup options.
Check that it works
diskutil list disk4
You should see the GUID_partition_scheme, a small EFI partition and your volume (with APFS you will also see a synthesized container). The drive should mount in the Finder with the name you gave it.
Common problems
“Resource busy” or “Couldn’t unmount disk”. A process is using the drive (Spotlight, Time Machine, an open app). Use diskutil unmountDisk force disk4 and repeat.
Erasing fails with a permissions or write-protected error. Many SD cards have a lock switch; check it is unlocked. Some damaged USB sticks become read-only and cannot be fixed.
The drive does not appear in diskutil list. Try another cable and port and avoid unpowered hubs. If it still does not appear, the problem is hardware or the enclosure, not partitions.
The drive has APFS containers that will not delete. Delete the container first with diskutil apfs deleteContainer disk5 (the container’s identifier, not the physical disk) and then run eraseDisk on the physical disk.
Windows does not see the drive afterwards. You formatted it as APFS or Mac OS Extended. Repeat with ExFAT if you will share it.
Frequently asked questions
Does this securely erase data? No: it removes partitions and the file system. On SSDs and NVMe the system itself makes deleted data very hard to recover, but if you need certified erasure use the manufacturer’s tool.
Can I do this with a drive from Windows? Yes, that is the most common case. If you want to do it from Windows, there is the guide to removing partitions on Windows.



