Had a USB drive that Windows refused to write to, throwing “the media is write protected” every time I tried to copy a file or format it. The drive itself had no physical write-protect switch – at least not that I could see. Here’s the full breakdown of what can cause this and how to fix each case.
Case 1: Physical write-protect switch
Some SD cards and USB drives have a small physical lock switch on the side. If this is engaged, it’s hardware-level write protection and no software fix will help. Check for a small slider on the side of the card or drive and move it to the unlocked position.
Case 2: diskpart clearreadonly
This is the most effective software fix:
- Open Command Prompt as administrator
- Type
diskpartand press Enter - Type
list diskto see your drives - Type
select disk #(replace # with the disk number of your drive) - Type
attributes disk clear readonly - Type
exit
This removes the read-only attribute at the disk level. Eject and reinsert the drive after running this.
Case 3: Registry edit
Sometimes the write-protect flag is set in the Windows Registry:
- Run regedit as administrator
- Navigate to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies - Double-click WriteProtect
- Change the value from 1 to 0
- Click OK and restart
If StorageDevicePolicies doesn’t exist, write protection is not being set this way and you can skip this step.
Case 4: Corrupted file system or bad sectors
If the above don’t work, the drive may have a corrupted filesystem that Windows is treating as read-only as a protective measure. Try:
- Right-click the drive in File Explorer > Properties > Tools > Check
- Or run
chkdsk X: /f /rin admin Command Prompt (replace X with the drive letter)
chkdsk can fix logical errors. If it finds bad sectors, that points toward hardware failure.
Case 5: The drive is actually failing
If nothing above works and the drive is reporting write protection that can’t be cleared, the most likely explanation is hardware failure. Flash memory has a limited write cycle life, and some drives set themselves to read-only mode to preserve data when they detect impending failure. This is a feature, not a bug – it’s protecting your data. Back up everything on the drive immediately and replace it.