2

Disk Utility (macOS Catalina 10.15.2) fails to erase my USB drive (64GB key, currently formatted in exFAT).

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *64.1 GB    disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:       Microsoft Basic Data Lexar                   63.9 GB    disk2s2

I've tried a bunch of commands that I've found here and there in the terminal, but none of them worked, like:

➜  ~ diskutil eraseVolume exFAT MyName /dev/disk2
Started erase on disk2
Unmounting disk
Error: -69888: Couldn't unmount disk
➜  ~ diskutil eraseVolume exFAT MyName /dev/disk2s2    
Started erase on disk2s2 Lexar
Unmounting disk
Erasing
Error: -69760: Unable to write to the last block of the device
➜  ~ diskutil eraseDisk FAT32 MYSD MBRFormat /dev/disk2
Started erase on disk2
Unmounting disk
Creating the partition map
Error: -69877: Couldn't open device
➜  ~ diskutil eraseDisk free EMPTY /dev/disk2
Started erase on disk2
Unmounting disk
Creating the partition map
Error: -69877: Couldn't open device

My USB drive appears as read only when i do CMD+I, I tried repairing the permissions but that failed too.

➜  ~ diskutil resetUserPermissions /dev/disk2 `id -u`
Ready to reset user permissions on disk2
Error encountered attempting to reset permissions for user 501 home directory on disk2: Permissions are not enabled on the disk (-69861)

Thx in advance for the help :)

4
  • Can you unmount the disk in Finder and then try it? – WGroleau Apr 6 '20 at 20:30
  • In this case (erase to exFat via Disk Utility), it fails too, unable to write last to the last block of the device – nmud Apr 6 '20 at 20:59
  • Instead of posting screen captures, can you please input this as text because none of it is searchable. To capture of the output of a command, simply pipe the output to pbcopy. For example disktutil list | pbcopy, then edit the original question with the info you just captured. Don't forget to format it! – Allan Apr 7 '20 at 1:25
  • I edited the question to replace the pictures – nmud Apr 7 '20 at 7:34
3

This is an attempt to write a canonical QA for this issue, as per the Meta post: Where is the list of canonical questions stored for Ask Different? This answer is based off a number of pre-existing answers expect it to be periodically edited with the goal of becoming a comprehensive information resource. *

Can't Access the Device

If you're having an issue where you can't access the device there are a couple things to check first:

  • Check for write protection.

    • On SD cards, there is a physical "write lock" switch that may become enabled. Make sure it's in the "up" position. If it's write protected on every SD , you may have an issue with the logic board itself.

    • On USB flash drives, there may be a physical switch or it may be write protected from via a write protect bit, or the chip may be modified from the factory.

  • Make sure you have the correct privileges. Sometimes the drive may have had user privileges assigned to them. Using an Admin account will usually get around this.

Fixing the Device

There are a few steps you can take, but all are destructive to the data on the device.

  1. Erase Disk. As the name implies, this does a simple erase of the disk and marks the free space as "empty" with no file system or partition scheme.

    $ diskutil eraseDisk free Empty /dev/diskX 
    
  2. Re-partitition the Disk. I like to force a rewrite of the partition map to something that macOS is familiar with like a GPT partition and HFS+ file system. You can use MS-DOS with MBR as well. use diskutil listfilesystem to get a full list of supported file systems.

    $ diskutil partitionDisk diskX 1 GPT HFS+ Untitled 100%   ← GPT with HFS Format
    
    $ disktuil partitionDisk diskX 1 MBR FAT32 UNTITLED 100%  ← MBR with MS-DOS
    
  3. Zero out the disk. Using this command writes zeros to every block of the raw device, meaning you're bypassing everything and accessing the device itself. This is the nuclear option because it will overwrite every single spot on the device with a zero. Triple check the device name!

    $ diskutil unmountDisk diskX            ← Only if necessary (you get a "Resource Busy")
    
    $ sudo dd if=/dev/zero of=/dev/diskX bs=1m
    

If none of the above works, it's likely the device has failed. On SD cards, this is actually quite common. Ask any photographer and they'll tell you that SD cards fail usually in the middle of paid gig which is one of the reasons they now make D-SLRs with dual memory slots


* Existing Questions/Answers

3
  • 1. & 2. didn't work, I had tested them before. So I tried 3. and it took 3 days to zero out the disk, but it's still not working unfortunately. ~ sudo dd if=/dev/zero of=/dev/disk2 bs=1m dd: /dev/disk2: end of device 61121+0 records in 61120+1 records out 64088969216 bytes transferred in 273592.584641 secs (234250 bytes/sec) – nmud Apr 10 '20 at 12:16
  • same problem, none of the proposed solutions here worked, even after diskutil unmountDisk /dev/disk2 I got dd: /dev/disk2: Resource busy when trying to wipe it with dd. – user5359531 Jul 29 '20 at 12:30
  • wait... it started working after I unplugged the device and plugged it back in... – user5359531 Jul 29 '20 at 12:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .