Disk Utility Cannot erase USB Drive (Error: -69877: Couldn't open device)

I have a PNY 128gb flash drive that I can no longer modify (can't delete files). I've tried to reformat it using Disk Utility but I get the following message and my usb is unmounted:

enter image description here

I've followed the solutions found from these two postings with no luck.

Disk Utility cannot erase

Disk Utility won't erase

When I type in 'diskutil eraseDisk free EMPTY /dev/disk2' into terminal my usb is unmounted just like before and I get this message:

enter image description here

Any ideas on what I can do to erase and reformat my USB drive? Any help is much appreciated. Thanks!


Solution 1:

Before trying anything more radical, do make sure (if you're using a microSD-SD adapter) that the adapter isn't write protected / locked. D'oh! It can be missed easily.

Solution 2:

When nothing else works, you can try reinitializing the flash drive back to the conditions similar to when it was manufactured.

First, you need to determine the file name for the flash drive. Insert the flash drive in a USB port and execute the following Terminal application command.

diskutil list

The file name will be /dev/disk followed by a positive integer. You should also see the phrase (external, physical). For example, my 16 GB flash drive produces the output shown below. So the file name is /dev/disk2.

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *15.5 GB    disk2
   1:                 DOS_FAT_32 WINSTALL                15.5 GB    disk2s1

Next, the command to reinitialize the flash drive is given below. If your file name was not /dev/disk2, make the appropriate substitution.

diskutil  partitionDisk  /dev/disk2  1  MBR  FAT32  MYUSB  R