So if the USB flash drive is write-protected or read-only
Tags: superuser, community, drivewrite, faqread
Published: 2021-11-25 17:06:46

---
title: So if the USB flash drive is write-protected or read-only
published: true
date: 2021-11-22 19:26:49 UTC
tags: SuperUser,community,drivewrite,faqread
canonical_url: https://stackallflow.com/superuser/so-if-the-usb-flash-drive-is-write-protected-or-read-only/
---

<header>
<p><span style="font-size: 1.2em; color: initial;">community-faq</span><span style="font-size: 1.2em; color: initial;">read-only</span><span style="font-size: 1.2em; color: initial;">usb</span><span style="font-size: 1.2em; color: initial;">usb-flash-drive</span><span style="font-size: 1.2em; color: initial;">write-protect</span></p>
</header>

When I plug in my USB flash drive, it shows up on my computer as _write-protected_ or _read-only_. I am unable to transfer data to it, nor can I modify or delete any files already stored on it. I also cannot repartition or reformat the drive using Windows Disk Management, DiskPart, GParted, or other tools. The drive does not have a write-protect switch.

Why did this happen and what can I do about it? Is there a way to remove the write protection?

(Note that this can happen with some memory cards, too, as they often use controllers similar to those used in flash drives. In some cases, the system may report that the drive or card was formatted successfully even though it was never actually formatted; the original data reappears when the device is reinserted.)

> _This question comes up often and the answers are usually the same. This post is meant to provide a definitive, canonical answer for this problem. Feel free to edit the answer to add additional details._

#### Accepted Answer

If the drive appears to be write-protected, start by inserting the drive into another computer to isolate the cause of the issue.

If you’re able to write to the drive from another computer, you might be experiencing one of the following problems:

1. **Filesystem corruption.** The drive might have a corrupted filesystem or other issue (possibly specific to a particular computer or OS) that can be corrected by using `CHKDSK` or a similar utility. If this addresses the problem, your drive is probably working normally. It’s also important to eject the drive properly before removing it or at least wait until the drive has finished writing, as [removal of the drive while it is writing data can cause low-level data corruption](https://superuser.com/questions/290060/can-flash-memory-be-physically-damaged-if-power-is-interrupted-while-writing).
2. **Incorrect Group Policy settings.** If you’re running Windows, it’s possible that your system’s Group Policy may be disallowing writing to external storage devices, including USB flash drives. The registry key `HKEY_LOCAL_MACHINESystemCurrentControlSetControlStorageDevicePolicies` should either be absent or set to 0; if it is set to 1, Windows will not allow writing to external storage devices.
3. (_SD cards only_) **Broken or altered write-protect switch in the card slot.** The mechanical lock switch on an SD card [is not connected to its electronics](https://superuser.com/questions/354473/is-the-lock-mechanism-on-an-sd-card-hardware-firmware-or-software-driver-os/354497#354497):  

> It is the responsibility of the host to protect the card. The position of the write protect switch is unknown to the internal circuitry of the card.

This means that hardware and software other than the card itself is responsible for checking the lock state of the card. If this mechanism isn’t working as designed, a SD card can appear to be write-protected even if it is otherwise functioning normally. Typically, this can be addressed by replacing the card reader, although faulty drivers or incorrect software configuration can also cause this problem.

* * *

If the drive is read-only no matter what computer you plug it into, or you’ve tried the above steps to no avail, then the drive has probably experienced a fault condition, and it’s generally not possible to remove write protection from a faulty flash drive. This behavior is typical of flash drive controllers when they detect a problem with the underlying [NAND](https://en.wikipedia.org/wiki/Flash_memory) (e.g. too many bad blocks). The write protection is intended to prevent this condition from actually causing data loss, e.g. [the NAND becoming unreadable altogether](https://superuser.com/questions/871850/usb-flash-drive-not-working-or-is-appearing-as-an-empty-disk-drive-disk-managem). For example, [SanDisk customer support says](http://kb.sandisk.com/app/answers/detail/a_id/8656/~/write-protect-error-on-usb-flash-drives):

> Write protection errors occur when a flash drive detects a potential fault within itself. The drive will go into write-protected mode to prevent data loss. There is no method to fix this.

Note that depending on the drive, there may in fact be ways to disable (or more accurately, reset) the write protection by reprogramming the flash memory controller, such as by using the techniques listed under “Potential Hardware-Specific Restoration” in [this answer](https://superuser.com/questions/871850/usb-flash-drive-not-working-or-is-appearing-as-an-empty-disk-drive-disk-managem/871851#871851). Doing this is _not_ a good idea because the write protection signals that a problem has been detected by the controller; **overriding this and continuing to write to the drive could result in data loss.**

* * *

The upshot of this behavior is that any data on the drive is still accessible. Because the drive is failing, **you should back up the contents of the flash drive as soon as possible and replace the drive**. (If the drive contains sensitive information, be sure to physically destroy it before you dispose of it.)

Getting data off the drive may be tricky because some data corruption may have already occurred by the time drive went into read-only mode. This commonly manifests itself as the filesystem experiencing low-level corruption causing the filesystem to appear as RAW or the OS prompting the format the drive. Recovering from this kind of corruption can be complicated because the filesystem cannot be directly repaired—the drive is, after all, write-protected.

You may be able to retrieve data from a drive corrupted in this manner by using data recovery utilities such as the open-source [TestDisk](http://www.cgsecurity.org/wiki/TestDisk). You can also get a drive of equal or greater capacity and copy over the failing drive’s contents sector by sector onto the new drive using [GNU ddrescue](https://www.gnu.org/software/ddrescue/), and follow up with a `CHKDSK` to fix the filesystem errors. If these fail, and the data is particularly valuable, you could send the drive to a dedicated data recovery service; however, these services tend to be very expensive due to their highly specialized nature and are rarely worth it.

The post [So if the USB flash drive is write-protected or read-only](https://stackallflow.com/superuser/so-if-the-usb-flash-drive-is-write-protected-or-read-only/) appeared first on [Stack All Flow](https://stackallflow.com).