Storage · Windows 11
Fix a USB drive that shows as read-only or write-protected
A USB drive that refuses every write is usually carrying a read-only attribute, a physical lock switch, or a file system error — and sometimes it is failing. Copy anything you need off it first, then clear the attribute and check the file system.
What you need
- Your files copied off the drive first. Read-only still lets you read. Copy everything you need to the PC before changing anything, because the later steps can erase the drive, and a drive turning read-only is sometimes a drive about to fail.
- The drive's disk number. The advanced route works by disk number, and picking the wrong number aims the commands at the wrong drive. You will read it from Disk Management before typing anything.
- An administrator terminal. The diskpart commands below only run with administrator rights.
Read the problem before you touch it
- Separate the three causes. 'Write-protected' and 'read-only' messages come from three places: a physical lock switch on the drive or its adapter, a read-only attribute set on the disk in Windows, or file system damage that makes Windows mount the drive read-only to protect it. Each has a different fix, in the order below.
- Check whether reading still works. If you can open and copy files off the drive, do that now, in full. If the drive also fails to read, or disappears and reappears, treat it as failing hardware and put recovery of the files ahead of any repair.
- Look at the drive in Disk Management. Right-click Start and choose Disk Management. Find the USB drive by its size, note its disk number, and read its status. A drive shown as Read-Only there confirms the attribute branch; a drive shown with a RAW or missing file system points at damage instead.
The simple fixes, in order
- Check the physical lock switch. Many SD cards, and some USB sticks and card adapters, carry a small sliding switch on the side. Slide it to the unlocked position, reinsert the drive, and try copying a small file onto it.
- Try another port and another PC. Plug the drive directly into a different USB port, not through a hub. If it writes normally in another PC, the fault sits with the first PC's port or policy, not the drive.
- Check the file system for errors. In File Explorer, right-click the drive, choose Properties > Tools, and run Check under Error checking. Windows mounting a damaged file system as read-only is a deliberate protection, and repairing the errors often hands write access straight back.
- Scan the drive. Right-click the drive in File Explorer and run your security software's scan on it. A detected threat can leave a drive locked down until it is cleaned.
The advanced route
- Clear the read-only attribute with diskpart. Open Windows Terminal as administrator and run
diskpart. At its prompt, runlist disk, thenselect disk Nusing the number you noted for the USB drive — check the size column twice before pressing Enter. Then runattributes disk clear readonlyandexit. Microsoft documents the command in diskpart and the attribute itself in attributes disk. - Test a write immediately. Copy one small file onto the drive, delete it, and copy it again. A drive that accepts writes now is fixed; a drive that reports read-only again straight away is re-applying the attribute, which points at the drive itself.
- Format only with the files already safe. If the attribute clears but the file system still misbehaves, format the drive from Disk Management — this erases everything on it, which is why the copy-off step came first. Choose exFAT for a drive used across Windows and other devices, or NTFS for a Windows-only drive.
End state
- You can copy a file onto the drive, rename it, and delete it, with no write-protected message.
- Disk Management shows the drive with a healthy file system and no Read-Only status.
- The drive keeps write access after being safely removed and plugged back in.
When it goes wrong
- The attribute comes back the moment you clear it. Flash storage that has worn out locks itself read-only permanently so the files stay readable. That lock cannot be cleared; copy everything off and replace the drive.
- diskpart says the drive is not the one you expected. Stop. Leave diskpart with
exit, re-read the disk numbers and sizes in Disk Management, and start again. Every diskpart command acts on the selected disk, and the internal drive is one wrong number away. - The drive shows as RAW. The file system is damaged beyond a simple check. The files may still be recoverable with recovery software, but formatting — the quick fix — erases them, so decide which matters more before formatting.
- It is read-only on every PC. With the switch checked and the attribute cleared, a drive that is read-only everywhere is the drive itself. Treat it as read-only storage for its remaining files and replace it.
Related fixes
-
Fix a drive that shows as RAW in Disk Management and asks to be formatted
RAW means Windows can no longer read the drive's file system — it does not mean your files are gone, and formatting is the one step that can finish them off. Leave the drive's contents alone, check it read-only first, and copy your data somewhere safe before any repair touches it.
-
Fix a USB flash drive that shows far less capacity than it should
A 64 GB flash drive that reports 8 GB is usually not broken — it is partitioned for something else, most often a boot installer it once carried. Disk Management shows the real layout, and the fix is to remove the old partitions and give the whole drive one new one.
-
Fix a drive that shows the wrong amount of free space in File Explorer
File Explorer's free space figure can disagree with reality when the Recycle Bin, restore points, or a stuck file system count is inflating the used side. Compare the numbers first, clear the quiet hoarders next, then repair the count itself.
-
Fix a drive that Windows asks to scan and fix every time you plug it in
The scan-and-fix prompt appears when a drive's file system was left in a dirty state — usually removed without ejecting, or unplugged mid-write. Let Windows check it once, properly, and change the removal habit that keeps setting the flag; if the prompt survives a clean check, the drive itself needs attention.
Sources
- Microsoft Learn, diskpart — the diskpart command reference, including listing and selecting disks.
- Microsoft Learn, attributes disk — setting and clearing the read-only attribute on a disk.