Erase process has failed. Couldn't open device: how to erase the drive anyway
Disk Utility cannot erase a drive while something holds it open, or while it is locked. Three causes, and the command that erases it when the window will not.
You click Erase and Disk Utility answers Erase process has failed. Click Done to continue. The detail usually reads Couldn't open device (-69877) or Couldn't unmount disk. Disk Utility could not get exclusive access to the drive. Something else has it.
The three usual causes
| Cause | How to tell | Fix |
|---|---|---|
| An app or process is using it | Erase fails within a second or two | Close apps, then unmount from Terminal (below) |
| The card or drive is locked | SD card, or a drive with a write protect switch | Slide the lock switch on the card or adapter to unlocked |
| The volume, not the device, is selected | Only the indented line is highlighted | View, Show All Devices and select the top line |
Find what is holding it
lsof +f -- /Volumes/YourDrive 2>/dev/null | awk 'NR==1 || !seen[$1]++'Spotlight (mds) and Quick Look are the usual ones. Our disk will not eject guide has the full list.
Erase it from Terminal
Terminal can force the unmount that Disk Utility gives up on. Read the identifier carefully: this erases the disk you name.
diskutil list external
diskutil unmountDisk force disk4
diskutil eraseDisk ExFAT "USB" GPT disk4Use APFS instead of ExFAT for a drive that only Macs will use. Our guide to formatting for Mac and Windows helps you choose.
When nothing works
If even diskutil cannot open the device, try a different cable and port, and a powered hub for a portable drive. An SD card that fails everywhere has usually reached the end of its life: cards switch to read only when they wear out, on purpose, to protect what is on them. Copy the files off and replace it.
Common questions
What does Couldn't open device mean in Disk Utility?
Disk Utility could not get exclusive access to the drive. An app is using it, the card is locked, or the volume rather than the whole device is selected.
How do I force erase a drive on a Mac?
Run diskutil unmountDisk force disk4 and then diskutil eraseDisk ExFAT "USB" GPT disk4 in Terminal, replacing disk4 with your drive's identifier from diskutil list. This erases everything on it.
Why will my SD card not erase on a Mac?
Check the lock switch on the card or adapter first. If it still fails, the card may have switched itself to read only because it is worn out.