How to fix – diskpart failed to clear disk attributes

Updated on May 14th, 2021

This post covers step-by-step instructions to fix diskpart failed to clear disk attributes issue that happens during running diskpart to clear read only disk attributes.

Symptom when diskpart failed to clear disk attributes

DiskPart is a text-mode command interpreter provided by Windows operating system. With this tool, you are able to complete many tasks by typing corresponding command in Command Prompt, for example, partition hard drive, create volume, format disk, clear disk attributes, etc. It is a quite handy tool, and yet it is not recommended to be used by beginner users. That’s because improper operations may lead to serious issue, such as data loss.

Sometimes DiskPart cannot work as expected, especially when the storage media contains errors. In that case, DiskPart will encounter various errors such as DiskPart has encountered an error, diskpart failed to clear disk attributes, etc. Let’s see a real world case together:

I have a 500GB WD hard drive which was bought for my desktop five years ago. It is crashed and uninitialized. I can see it in Disk Management as an unallocated and uninitialized HDD. I couldn’t create new volume on it in Disk Management or using DISKPART. Someone told me the media is write protected. Thus I tried to move read only by attribute disk clear readonly command but ended up with error ‘diskpart failed to clear disk attributes’. Does anybody know how to fix it?

Causes

  • The device causes the issue might be set as read-only, hidden or nodefaultdriveletter
  • The storage media contain physical damage such as bad sectors.

Solutions to fix diskpart failed to clear disk attributes

Solution 1: Remove disk write-protection

  1. Check the device for a physical lock. Some USB flash drives and memory cards have a physical lock which is used to set write-protection. Thus you should make sure the switch is placed to the unlocked side.
  2. Check whether the drive is running of out space. If there is no more free space on the drive and you try to save data on it, you are likely to get write protection error.
  3. Check file’s attributes. Right-click the file or folder in File Explorer and select Properties, then you can view whether the “Read-only” option is selected. If yes, uncheck it and click OK.
  4. Now you can retry DiskPart to clear disk attributes again.

Methods to remove write protection should not be limited to what have been mentioned here, you can find more approaches from the guide: The disk is write-protected.

Solution 2: Check and repair bad sectors

Bad sectors are sectors on storage devices that have been damaged and lose the ability to read or write data. Since bad sectors no longer respond to any read or write requests, diskpart command cannot complete any tasks anymore. The follow steps will introduce how to check and repair bad sectors.

Disclaimer: Bad sectoring repairing damages data stored on or near bad sectors, thus you should make sure all files have been backed up before performing any repairing actions; not all bad sectors can be repaired by this software, such as physical bad sectors. If your drive is badly damaged, you should send it to an experienced repair center.

Step 1: Install and run DiskGenius (old name PartitionGuru) Free edition from your computer. Locate the disk in question in DiskGenius (old name PartitionGuru), then click “Tools” and select “Verify Or Repair Bad Sectors” .

diskpart failed to clear disk attributes

Step 2: Now you can see the bad sector verifying windows where you should click “Start Verify” button.

diskpart failed to clear disk attributes

Step 3: DiskGenius (old name PartitionGuru) is checking bad sectors for select disk and marks bad sectors using red block.

diskpart failed to clear disk attributes

If any bad sectors are found, you can click “Repair” button to try repairing them.