Diskpart Error Media is Write Protected – Causes & Solutions

  Amit Patra
Written By Amit Patra
Anuraag Singh
Approved By Anuraag Singh  
Modified On August 28th, 2025
Reading Time 5 Minutes Reading

If you are working with a USB drive, SD card, or external hard drive, you might have come across this diskpart error Media is write-protected. This error appears when your storage medium does not allow any modification, like formatting, deleting, transferring files, etc. Moreover, this is a frequent issue among Windows users, especially when trying to execute the clean or format command on a disk via Diskpart.

In this write-up, we will discuss the reasons behind this issue, a step-by-step procedure to resolve it, as well as a permanent solution if none of the manual methods work.

Table of Contents Hide

Why Does the “Diskpart Error Media is Write Protected” Occur?

Here are some of the reasons related to the diskpart error media is write protected:

  • Physical write protection switch − Many SD cards and USB drives have a small switch responsible for toggling the write protection level.
  • Corrupted File System – A corrupted file system could put the device in READ-ONLY mode.
  • Registry restrictions – Windows can place limitations via registry entries.
  • Malware infection — Some strains of malware will latch onto the drive to make it harder to remove malicious files.
  • Physical damage to storage media – When a storage medium, such as a hard disk, SSD, or memory card, has bad sectors or other forms of hardware failure. Then, it could become permanently write-protected.

Methods to Fix Diskpart Error Media is Write Protected

With this much info, let’s dive into the step-by-step guide to resolve this problem.

Method 1: Check the Physical Lock Switch

There are some removable drives, especially SD cards, with a lock slider feature. So, when the slider is set to “Lock”, you will get the error “diskpart media is write protected” in Windows.

  1. Remove the card/drive from your PC.
  2. Next, look for a small switch, generally found on the side of an SD card.
  3. Slide the slider to the “Unlock” position.
  4. Put in the drive and try accessing or formatting it.

It is the easiest fix, and this will work right away if the lock switch is the cause.

Method 2: Use Diskpart Command Properly

If the physical lock does not seem to be the problem, you can try removing write protection with Diskpart:

  • Begin by pressing Win and R together and type cmd in the Run dialog box. Then, hit Enter button.
  • Run diskpart.
  • Enter the following commands:

list disk

select disk X   (replace X with your drive number)

attributes disk clear readonly

exit

  • Now, try formatting the drive.

If the process is executed successfully, the diskpart error media is write protected message will disappear.

Method 3: Edit Windows Registry

In some cases, Windows registry policies enables write protection. To disable them:

  1. At first, press Win + R and run regedit, and hit Enter.
  2. Navigate to:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies

  1. If you see an entry named WriteProtect, double-click on it.
  2. Change its value from 1 to 0.
  3. Try restarting your system and reconnecting the drive.

This policy should fix the diskpart media is write protected error if this policy was be active.

Method 4: Use Group Policy Editor

On Windows Professional editions, write restrictions may be imposed by the Group Policy Editor.

  1. Firstly, hit Win + R together and type gpedit.msc, and press Enter. Then go to:

Computer Configuration > Administrative Templates > System > Removable Storage Access

  1. Look for and then tap on “Removable disks Deny write access”.
  2. Set it to Disabled.
  3. Restart your computer.

Doing this can help you to disable write protection and fix the error.

Method 5: Scan for Malware

Some of the malware may intentionally lock your drive, so you cannot delete it. Use Windows Defender or a third-party Antivirus to begin a complete system scan. Thereafter, once you have removed all threats, check the drive again.

Method 6: Check for Bad Sectors

Diskpart error media is write protected message can also be caused by physical damage. Therefore, you can run a disk check:

  1. Open Command Prompt as Administrator.
  2. Type:

chkdsk X: /f /r

(Change X with your drive letter).

This process scans for and tries to fix any issues. Also, if the problem is because of bad sectors, this could restore usability.

Method 7: Format the Drive via Disk Management

If none of the above method works, you can format through Disk Management:

  • Right-click on This PCManageDisk Management
  • Right-click your driveFormat.
  • Choose a file system (NTFS/FAT32).
  • Proceed with formatting.

If formatting also does not work, your device may be damaged forever.

Alternative Way for a Permanent Solution

If you have used all the above manual approaches, yet you are still getting the error – diskpart error media is write protected, you should opt for a reliable tool. Using SysTools Data Shredding Software is one of the best practical solutions to wipe data from write protected drive or safely wipe data without worrying about write protection in several cases. Furthermore, it offers a trusted means of wiping a drive and confidential data that Windows tools cannot reformat.

 

Final Thoughts

In most cases, it can be very annoying when the diskpart error media is write protected occurs while you need the storage device urgently. The foremost and basic fixes can be checking the lock switch, then moving to the registry and group policy methods. In severe cases, it is necessary to help professionals, advanced software to wipe hard drive thoroughly and reuse it. If it still does not work, it is likely that the drive has suffered irreversible physical damage and should be replaced.

  Amit Patra

By Amit Patra

An adept expert with an extensive experience in solving a wide range of technical challenges. Passionate about emerging technologies, creating practical solutions, and simplifying complex concepts in layman's terms for users. Skilled in cybersecurity, data management, cloud platforms, and other domains, with proven expertise in providing user-focused content. His insights are a blend of hands-on experience, research and continuous learning.