Wednesday, February 2, 2011

Fix Media is Write Protected in Windows 7

Over the years, one annoying and hard to fix problem I’ve come across in Windows XP, Vista and 7 is the media write protected error. You’ll be going about your day just fine when all of a sudden you can’t write any files to your local hard drive, a USB drive, or an external drive attached via eSata, etc.
Common error messages you get for this are:
Media is write-protected
The disk is write protected
Unfortunately, there is no clear cause of this error in Windows, which makes it all the harder to fix! Add to the fact that this error message normally does not have anything to do with ownership or permissions and it really confuses the heck out of people.
The most common solution I’ve seen tried for this error is to try and take ownership of all files, folders or drives that are write-protected. You do not want to do this! 99 out of 100 times, permissions on the drive have not changed. Instead, it’s a problem with Windows 7, Vista, XP or third-party software.
Before you try taking ownership or changing permissions, try out the following solutions and see if they work for you.

Method 1 – Diskpart

Using the built-in Diskpart tool that comes with Windows XP, Vista and 7, you can check whether or not the drive or volume is set to read-only. If it is, you can then use diskpart to remove the read-only property.
First open a command prompt and type diskpart. You’ll be brought to the diskpart prompt.


 

Now type in list volume or list disk to see the list of disks and partitions on the computer.


Now you have to select a volume or disk to check whether it is read-only or not. If I wanted to select the C drive (boot drive), then I would type select volume 2.


Now type attributes volume to see the various attributes of the volume. One of them is read-only.


As you can see from above, this volume is not read-only. Also note that when you type list volume or list disk, the Info tab will tell you whether the disk is removable or not.
Finally, to remove the read-only flag on a drive or volume, type the following command after you have selected the appropriate volume or disk:
attributes volume clear readonly
attributes disk clear readonly
Note that this normally fixes the problem in Windows 7, but it may not remain in place after a reboot. This can happen if the drive is being made read-only again by some other program or the OS. Read on for other solutions if this is not working for you.

Update Hard Disk Drivers

If you’re running Windows 7 64-bit and have multiple hard drives with AHCI enabled, you might experience this problem.
The best thing to do here is to download the latest drivers for your hard disks (SATA/ RAID Controller) and for any hard disk controllers. If you’re having this issue with a NAS device connected to your computer via eSata, updating the drivers should fix your problem.

Check Registry Key

If your system has been recently infected with a virus or spyware, the malware could have modified a registry key making any device connected to your computer write-protected.
Open the registry editor and go to the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies
If the key StorageDevicePolicies does not exist, create it manually. You can do this by right-clicking on the Control key and choosing NewKey. In the right-window, double-click on WriteProtect and set the value to 0. If WriteProtect does not exist, then right-click on the new StorageDevicePolicies key and choose NewDword.

Disable Backup and Antivirus Software

Depending on what kind of backup or antivirus software you are running, your disk or volume might be set to read-only by software installed on your system. Sometimes these programs can mistakenly make a volume or disk write-protected.
One example is the Avira Antivirus software. If it finds a virus and cannot remove it from a USB stick, it can go ahead and write protect the drive on it’s own!

Fix MBR

In some cases, the MBR on the drive can become corrupted and therefore cause the drive to only have read-only access. If it’s an external drive, you can still run FixMBR using a free utility.
You can use the following command to repair the MBR on the drive:
Mbrfix /drive {drive num} fixmbr {/vista | /win7}

System Restore

Your last option is to perform a system restore if you recently installed some new software or installed a new update to your system. Try to roll back to a restore point that is earlier than when you started having the problem and see if that fixes the issue.