There’s no such thing as process ID 0. It looks like disk utility is using this as a placeholder to represent kernel-space code, which may be running independently of any user-space processes.
This looks like a fairly common problem. I’m not sure what this particular error code means, but people seem to get it if media is write-protected or if some part of the partition table or a volume is corrupted.
That being said, here are some things to try:
Check for write protection
SD cards have write-protect sliders on them. Some external drives or drive enclosures might also have write-protect switches. Make sure write protection is disabled or you (obviously) won’t be able to erase it.
Check to make sure some process isn’t actually using the device
If some process has open files on the device, or if it just holding the device itself open, that will make it impossible for Disk Utility to unmount it until those processes end or close their handles to the device.
A command like this may help you determine if this is going on:
lsof +c 0 | grep disk6
(replacing disk6
with the device’s actual name). Look in the leftmost column of each output line for the name of a process that has the file open.
It may be that the system is trying to check/repair one of the device’s volumes prior to mounting, and that activity is taking a long time (which might be the case if some corruption was discovered). A telltale of this will be that a process named fsck
or something similar (e.g. fsck_apfs
or fsck_hfs
) will be using the device.
If this, or something similar, is the case, then you should just wait for the background processing to finish. You can repeat the lsof
command to see when the process terminates or is no longer using the device. Then give it a try.
Some have suggested booting into Recovery mode and trying to erase it from there. Which might or might not work, depending on what process is holding the device open.
Encrypted volume?
A few links I found in a web search indicate that you may not be able to directly erase a device if there are encrypted volumes on it. But you may be able to use Disk Utility to erase or delete the volumes first, and then erase the device.
Corrupted content?
It is possible that something got truly messed up in the drive’s partition table or one of its volumes such that it can neither be mounted nor unmounted. That’s happened to me on occasion, especially when trying to erase something formerly formatted as NTFS.
In such situations, you can use the dd
command to just write zeros over the start of the device (the first few blocks should do it, but I usually overwrite the first MB or so, just to be sure). This will write zeros to the first 10M:
sudo dd if=/dev/zero of=/dev/disk6 bs=1m count=10 status=progress
Or this will write zeros the the entire device (which will probably take a long time):
sudo dd if=/dev/zero of=/dev/disk6 bs=1m status=progress
(The status=progress
option isn’t necessary, but without it, the dd
command will not show any output until it finishes, making it impossible to tell if it’s working or hung if it’s taking a long time.)
After erasing, disconnect and reconnect the drive. macOS should prompt you to format it when it is reconnected.
But I’d consider this a last resort. And be very very careful with a command like this, because a typo could result in wiping a different device, which will completely ruin your day.
See also: