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

13,786

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.

Share:
13,786

Related videos on Youtube

akris
Author by

akris

Updated on September 18, 2022

Comments

  • akris
    akris over 1 year

    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?

    • Leo Chapiro
      Leo Chapiro over 7 years
      Take a look and "Bear in mind that there is no guarantee that they will work for you: your USB flash drive or SD card may be corrupt or physically broken and no utility or low-level formatting tool will make it work again. The only solution in this case is to buy a new drive.": pcadvisor.co.uk/how-to/storage/…
    • akris
      akris over 7 years
      Thanks for the answer. I have already checked that and didn't helped me. I know, otherwise if guarantee was valid for me i would never give back a USB with my personal data just to replace it. I really wonder though why that happened, because it wasn't physically broken or something. For real it just happened, that's why i supposed it can be solved. But i really doubt now.
    • Tetsujin
      Tetsujin over 7 years
      The solution is always the same. Get any data you need/can from it, then bin it or smash it & use another one.
    • akris
      akris over 7 years
      Unfortunately yes, the USB is useless now. But i still cannot understand how there is not away to fix that. At first i thought it would be just a chmod issue or something and not that big.
    • Ale..chenski
      Ale..chenski over 7 years
      What is the maker of your "a USB Drive" ?
    • akris
      akris over 7 years
      It's a SanDisk USB.
  • Tetsujin
    Tetsujin over 7 years
    Ali - you ought to add that info to bwDraco's community answer on the linked question. I already knew the gist of it but not the detail. It's canonical enough to stand as part of that answer, imho.
  • akris
    akris over 7 years
    I have read about that and i understand why that happens and what causes it. But for me it looks so bad that you cannot fix that, not only from the waste of money aspect. It looks like an if without an else.
  • Ale..chenski
    Ale..chenski over 7 years
    @D1m, thanks for mentioning that the flash is made by SanDisk. This correlates with other cases. Actually, I don't understand why it happens. It shouldn't happen in such short time span, or under any unlucky detachment/attachment. I think SanDisk has an ugly bug in their chips.
  • akris
    akris over 7 years
    The USB is brand new i only have 2 weeks and the problem appeared at the first week. The irony is that i have bought SanDisk USBs at the past and had good experience, that's why i bought another one. For sure it was the last one. As i have read on my search i saw too that SanDisk faces that problem at their USB not so rarely.
  • Ale..chenski
    Ale..chenski over 7 years
    @Tetsujin, I have a disagreement with bwDraco on this matter. He believes that this "read-only" or dead flash drive issue is a result of some general system hick-up that is common to all USB flash media, while I believe that this is a problem with some particular hardware/firmware employed by certain manufacturers. See my comments there, and his reaction.
  • Tetsujin
    Tetsujin over 7 years
    That may be, but concatenated info has got to be better than having it spread over 42 answers... Eventually, we may find the commonality.
  • Ale..chenski
    Ale..chenski over 7 years
    @Tetsujin, how can I concatenate my bit of info into the "communiity" answer? Is there a mechanism to do this?
  • Tetsujin
    Tetsujin over 7 years
    @AliChen - you can just hit the edit tag, same as any answer. You have enough rep that it won't need peer review. As it's community wiki, no-one gets points for it, it's simply setting out to become the canonical answer, over time