18

I have a 4GB HP USB flash drive that I had written a Chromium OS image to with Win32DiskImager. Now I am trying to reformat it but I can't. Everything tells me the disk is write protected. Being a USB flash drive, there is no write-protect switch. I have tried the standard windows format thing, disk management, diskpart and HP USB Disk Storage Format Tool. I also tried the registry modification. Any ideas? Here is the results of trying to use diskpart:

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>diskpart

Microsoft DiskPart version 6.3.9600

Copyright (C) 1999-2013 Microsoft Corporation.
On computer: BRANDON-PC

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          931 GB  1024 KB
  Disk 1    No Media           0 B      0 B
  Disk 2    No Media           0 B      0 B
  Disk 3    No Media           0 B      0 B
  Disk 4    No Media           0 B      0 B
  Disk 5    No Media           0 B      0 B
  Disk 6    Online         3824 MB      0 B

DISKPART> select disk 6

Disk 6 is now the selected disk.

DISKPART> attributes disk clear readonly

Disk attributes cleared successfully.

DISKPART> clean

DiskPart has encountered an error: Incorrect function.
See the System Event Log for more information.

DISKPART> create partition primary

DiskPart succeeded in creating the specified partition.

DISKPART> format fs=fat32

    0 percent completed

Virtual Disk Service error:
The media is write protected.


DISKPART> exit

Leaving DiskPart...

C:\WINDOWS\system32>

Even after using "attributes disk clear readonly" it still says the media is write protected. I think it's because the clean operation fails.

Sega dude
  • 298

7 Answers7

9

If none of the other suggested answers here work, then your USB flash drive is probably going bad.

There is a controller chip on the USB stick that manages the flash memory. If the flash controller detects any kind of unrecoverable error with the memory cells (a reallocation failure, for example), then it trips a safety condition and makes the drive read-only at the firmware level to protect your data.

Unfortunately, there is no way to get the drive out of this condition without the factory software for your drive. Flash drive manufacturers do not make this software available to the public, so the only way to get it is from Chinese hack sites.

Your only option here is to replace it. The top brands (Kingston, SanDisk, Lexar, etc.) provide lifetime warranties on their products. I have no idea how to go about getting that warranty though. But with flash drive prices being what they are, it's probably better to just go buy a new one -- unless it's a really nice one.

Wes Sayeed
  • 14,102
6

Being a USB flash drive, there is no write-protect switch.

Well, there are USB flash drives with (sometimes very well hidden) write-protect switches. I don't know of any such drive made by HP though.

Assuming your drive doesn't have such a switch, seeing what you've already tried, I think you need a new one. I've had two flash drives from different manufacturers that suddenly were read-only, and there was no way of fixing it.

I don't have any sources on this, but I assume this is a protection mechanism diminishes the risk of total data loss when the flash drive starts failing.

Dennis
  • 50,701
5

There are a couple of ways to fix this problem. Some of them are mentioned in the other answers, but I don't think that is the case. I've had the same issue before. Here's what you have to try...
1. Download a tool called CheapEasy and check your device VID and PID.
2. Go to http://flashboot.ru/iflash/ and enter the device VID or PID and search for the flash tool for your device. To make sure you get the right one, check on the CheapEasy tool for your Flash Part number or flash ID, which usually will be on the description of the flash tool you have to download.

P.S. If you have trouble finding the right tool, export you device information and send a link so I can check it. It might look impossible to find the right one, but I've fixed almost all types of USBs, expect some chinese copies of Kingston USBs.

Erlis D.
  • 828
4

Try this if using cmd doesn't work:

Removing write-protection in the Registry using Regedit.exe

  1. Search and open regedit.

  2. Navigate to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies.

  3. Double-click on the WriteProtect value in the right-hand pane of Regedit.exe. Change the Value data from 1 to 0 and click OK to save the change.

  4. Close Regedit and restart your computer.

Connect your USB drive again, and you should find it is no longer write protected. You can now format the drive as normal by right-clicking on it in My Computer and choosing Format.

After formatting you may revert the settings(0 to 1) or if you created the value, then delete it, then reboot.

Note:

If you can't find StoredDevicePolicies then you have to create one by right clicking on Control > New > Key and name it as StoredDevicePolicies. Now create WriteProtect by right clicking on Stored Device Policies> New > DWORD and name it as WriteProtect.

*DWORD chosen depending on your system: 32bit or 64bit.

By the way, some flash drives have a switch too. And be aware that this could also be caused by the USB's fails safe, where all reserved sectors that could be mapped in by the continuously generated bad sectors are exhausted.

Rsya Studios
  • 3,716
1

I ended up fixing it by re-partitioning it using Disk Utility on my MacBook. This was back before El Capitan, when Disk Utility was redesigned. I made it one partition and formatted it as MS-DOS File System. It's been working fine ever since.

Sega dude
  • 298
1

Open cmd.exe with administrative privileges and execute this command:

To unlock write-protect usb:

reg add "HKLM\SYSTEM\ControlSet001\Control\StorageDevicePolicies" /v WriteProtect /t REG_DWORD /d 0 /f

To lock write-protect usb:

reg add "HKLM\SYSTEM\ControlSet001\Control\StorageDevicePolicies" /v WriteProtect /t REG_DWORD /d 1 /f

For the changes to take effect, you must restart the PC and / or disconnect the USB storage device and reconnect it.

acgbox
  • 844
1

If you have a Linux somewhere (computer, cd, live-usb, etc), try to use dd in order to erase and write every bit of your usb key of zeroes. That Linux command never fails, and if it can't rewrite anything on your usb key, it's definitely over for it.

To make it fast, do you have any Linux on your computer ?

You said you got an ubuntu, so you'll need to install gnome-disk-utility or palimpsest in order to determine the right disk to erase. Once it's installed, you should find it as "Disk Utility" or simply Disks like here:

https://en.wikipedia.org/wiki/GNOME_Disks

Just connect your usb key and then look which drive it is, like sdb or sdc, etc

Once it's done, open a terminal, become root and do the following command, X being the whole correct drive:

dd if=/dev/zero of=/dev/sdX

The terminal will now hang until it's done, and will show you how much bits was written, and say "no left space on device".

Note that it can take long, but assuming you have 4GB, it should take an hour at 2MB/s if you have a slow usb-key. The worst I ever had reached also an hour at 0.5MB/s for a 2GB uSD card. Plus, do not EVER ctrl-c an ongoing dd command, it can cause errors on the device, even if it doesn't often occurs.

You should now have a completely erased device. Go back to gnome-disk-utility to eject your usb key.

Reconnect it and then use gnome-disk-utility again in order to create a partition after creating a Master Boot Record.

X.LINK
  • 2,448