Are you getting the DiskPart failed to clear disk attributes error when trying to clear the attributes of a drive? Don’t worry, you’re not alone.
This can be a very big issue, especially if you are trying to format your drive or make it bootable. You won’t be able to use DiskPart commands on such drives. Fortunately, there are a few solutions that you can try in order to fix this problem.
In this article, we’ll show you how to fix the DiskPart failed to clear disk attributes error in Windows 11, 10, 8, 7, Vista, and XP.
How to clear Read-only Atriibutes using DiskPart?
To clear the attributes on a USB drive, follow these steps:
- Press Windows + X keys on your keyboard and select Command Prompt (Admin) from the menu.
- In the command prompt window, type the following commands and press Enter after each:
- list disk
- select disk X (Replace X with the number of your drive)
- attributes disk clear readonly
While clearing the read-only attribute you might get the “DiskPart failed to clear disk attributes.” If that is the case, read further about what it is and how to fix it.
What is the “DiskPart failed to clear disk attributes” Error?
The “DiskPart failed to clear disk attributes” error is caused by a problem with the DiskPart utility. It arises when you try to clear the disk attributes. This utility is used to manage partitions, drives, and other storage devices in Windows.
When you try to format or partition a drive using DiskPart, you may see the following error message: “DiskPart failed to clear disk attributes.”
There are a few things that can cause this error, here are those:
- It is possible that the drive is write-protected. A write-protected disk won’t allow DiskPart to run any command.
- There might be a physical switch that has made the USB drive write-protected.
- The drive may be in use by another process. This can happen if you have another program open that is using the drive.
- Possibly the drive may be corrupted. This can happen if the drive has been damaged or if it was not formatted properly.
- There are bad sectors on the drive. This can cause the drive to be unreadable by DiskPart.
- If the drive is in RAW format, it might be difficult to clear its attributes as Diskpart does not work well with the RAW format.
- The file system on the drive may be corrupted. This can happen if the drive was not formatted properly or if it was damaged.
How to fix “DiskPart failed to clear disk attributes”?
There are various solutions to fix the DiskPart failed to clear disk attributes. Depending on the root cause, you can apply one of the solutions.
Here are the top solutions.
Turn Off the Physical Switch
Some external drives such as USB flash drives, SD cards, and so on include a physical write-protection button. The storage device’s writable options will be disabled, blocking DiskPart from changing the disk attribute to writable, if this switch is activated.
If you are unable to clear disk attributes read-only on external drives using DiskPart, check for a physical write-protection switch. If there is one, turn it off. Then, after restarting the Windows Explorer process, run the attributes disk clear read-only command again to see whether the problem has been fixed.
Modify WriteProtected Key in Registry Editor
If there is no physical switch on your external drive, the problem might be caused by a registry key.
To fix this issue, you can try modifying the WriteProtected key in Registry Editor. Here’s how:
Press Windows + R keys on your keyboard to open the Run dialog box.
Type Regedit and click OK to open Registry Editor.
In the left pane of Registry Editor, navigate to the following location: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies
Now, in the right pane of the StorageDevicePolicies key, look for an entry named WriteProtect. If it exists, double-click on it to modify its value.
Set its Value data to 0 and click OK to save changes.
Close Registry Editor and restart your computer.
Check and Repair Bad Sectors
Bad sectors on the drive can make it unreadable by DiskPart. You can use the chkdsk command to check for and repair bad sectors on your drive.
To do that:
- Press Windows + X keys and select Command Prompt (Admin) from the menu.
- In the command prompt window, type chkdsk F: /f (replace F with the drive letter of your storage device) and press Enter.
- The scanning process will start. Once it’s finished, restart your computer and check if the problem has been fixed.
Change the USB Drive’s Format
If you have a USB device with the RAW format, it’s likely that you won’t be able to alter the storage device’s disk attribute. Diskpart doesn’t operate correctly in RAW formats, as previously said. In order to fix the problem, we will try to change the drive’s format and then attempt to access it.
- Launch Command Prompt with Admin rights.
- Type diskpart command to open DiskPart.
- Now under DISKPART, type the following commands one by one:
- list volume
- select volume 7 (replace ‘7’ with the volume number of the drive)
- format fs=fat32 quick (you can also change the format to NTFS or EXFAT)
- Now plug out the USB drive and re-insert it after some time. Check if it needs to clear attributes, if yes, use DiskPart to clear attributes. Since the format is changed, DiskPart should now work properly.
Check your USB Hardware
If none of the above methods work, it’s reasonable to assume that a hardware problem on the storage device is causing the DiskPart failure to clear the disk attributes issue. When the lifespan of a flash drive is about to run out, this problem is very probable.
Contact the store nearest to you and request that they examine the storage device if you have a warranty. If it’s a hard drive, you may also try connecting it to other ports or changing the data cable.
These are several solutions that can be tried when DiskPart failed to clear disk attributes. If one of these solutions works, the problem will be fixed and you will be able to continue using your storage device as usual. If not, you may need to replace the USB hardware or contact customer service for help.
That’s it! We hope you found this article helpful. If you have any further questions, feel free to post them in the comment section below and we’ll do our best to answer them as soon as possible.
Yes, you can. If your USB drive is write-protected, you can try using the attributes disk clear read-only command in DiskPart to remove the write protection.
If your flash drive is corrupted, you can try using the chkdsk command to repair bad sectors on the drive.
If your USB drive won’t format, you can try changing the drive’s format using the DiskPart utility.
Peter is an Electrical Engineer whose primary interest is tinkering with his computer. He is passionate about Windows 10 Platform and enjoys writing tips and tutorials about it.