I can't remove the write-protection from a USB Drive [duplicate]

I know this is a duplicate question, maybe triple duplicate or more, but I really cannot find a solution for this. My USB Drive wasn't write protected before, but something happened to it and now I cannot write to or format it.

I have tried in ubuntu to change the permissions, fsck, fdisk, dmesg | tail, mkfs -t vfat, hdparm -r0 and nothing works; all I get is Permission Denied. I tried from GParted but it also says it's read only. I have also tried using Windows to change permissions, setting attributes disk clear readonly, renaming the key in the registry, and tried a low level format.

But truly nothing works. Also, the stick doesn't have any hardware pin or switch for write protection.

Is there any solution to this or should I just give up?


Solution 1:

The canonical answer is already given - get data out and trash the stick.

USB Mass Storage class of devices uses a subset of SCSI commands to operate flash drives above USB physical layer. There is REQUEST SENSE command (see Section 5), which returns a bunch of status data, including code "07" - WRITE PROTECTED MEDIA. All this bits are set inside the USB-to-flash bridge chip, by chip's embedded firmware. If the firmware has decided (as SanDisk once explained) to set this bit "for protection of possible user data corruption", there is no way to "unset this bit", at least people didn't find any way to circumvent the firmware.

Formally, this WRITE PROTECTED MEDIA bit is just to inform the host that it should not attempt to write to this media. If a host driver gets the WP status from media, it will not attempt to write. To circumvent this, the host driver must be hacked. Some media controllers might accept and execute the write command even if the bit is set. But apparently there are controllers IP that are overly protective, and will refuse even this hack on host side if their firmware logic has come to a conclusion that the media exhausted its reliability thresholds.