Wondershare Recoverit

File Recovery

  • Recovers deleted or lost files effectively, safely and completely.
  • Supports data recovery from 500+ data loss scenarios, including computer crash, partition loss, accidental human error, etc.
  • Supports 1000+ file formats recovery with a high success rate and without any quality loss.
Free Download Free Download Free Download Learn More >
file recovery

How to Fix Diskpart failed to clear disk attributes in Windows

Wondershare Recoverit Authors

Jan 15, 2024 • Filed to: Windows Computer Solutions • Proven solutions

If you’re familiar with Diskpart and use it to manipulate your device’s drivers, you may encounter a problem saying that it failed to clear disk attributes. In this article, we will provide you with 8 solutions to fix this error.

Part 1. Overview of Diskpart

Diskpart is a command disk partition tool built-in Windows. It’s commonly used to perform disk partitionings. Sometimes, when using this utility, you might come across the error: Diskpart failed to clear disk attributes. This usually happens if you attempt to modify storage media, such as changing a read-only device. This may due to your storage device is write-protected (usually in external hard drives and USB flash drives). It may also be due to bad sectors present in your disk or your new storage media in RAW format. This happens when file systems are corrupt, or there are problems with the hardware. Another common cause is when you’re not running Diskpart as an administrator. This limits your access.

Part 2. Solutions to Fix Diskpart failed to clear disk attributes

For whatever reason you may be encountering this error, there are sure solutions you can use. Here are 8 solutions to Fix Diskpart that failed to clear disk attributes.

Method 1. Make Sure Physical Switch On The Storage Device Is ON

Although not very common, some external storage media like hard drives and USB flash drives have a physical switch.


Because this isn’t very common for most drives, most users overlook this. But it’s a handy feature. It serves as extra protection for the accidental altering of any data contained within the device. Once the physical switch is set to on, Diskpart can’t make any changes to the disk.

If you’ve already switched on your drive or if it doesn’t have any physical switch and you’re still unable to fix the error, proceed to the next solutions.

Method 2. Use Registry Editor and Change WriteProtected key

Step 1. Press Windows key + R on your keyboard to launch Run.

Step 2. Once Run is open, type in regedit in the space and press Enter to open Registry Editor.

Step 3. Go to the following path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies

Step 4. This will show you a list. Find the WriteProtect registry option, which is found on the left-side menu, and double click it.

Step 5. You will be asked to assign a value. Change it to 0 and select OK to apply the changes. Close Registry Editor.


Method 3. Use CHKDSK to scan for drive errors

Step 1. Press the Windows key + S to launch the search tool. You can also look for it in the Start menu.

Step 2. In the search tool, type in the command prompt in the space. Look for Command Prompt and right-click on it to launch it. Choose Run as administrator.


Step 3. The Command Prompt window will pop up. Use the following command and press Enter (you may copy and paste this):

CHKDSK [volume [[path] filename]] [/F] [/V] [/R] [/X] [/C] [: size]]

*[/F] command fixes system errors, [/R] command fixes bad sectors

Step 4. You will be asked if you want to restart your device. Type in Y to reboot it.

Method 4. Clear attributes on RAW

Step 1. Press the Windows key + S to launch the search tool. You can also look for it in the Start menu.

Step 2. Type in diskpart in the search bar to launch it. A User Account prompt will pop up, select Yes to continue.


Step 3. The Command Prompt window will open. Type the following commands, pressing Enter after every command.

NOTE: ‘n’ stands for the drive’s volume number, change it to whatever your drive’s volume number is.

Step 4. After typing in all the commands, unplug the removable storage device and plug it again.

Step 5. Check if the error persists.

Method 5. Check the hardware components

Step 1. If your computer is off, turn it on. It’s currently running, restart your device.

Step 2. The Basic Input Output System (BIOS) screen should appear. If it doesn’t, restart your PC again. In the BIOS screen, repeatedly press the F8 key. This will open the Advanced Options feature.


Step 3. You can use your keyboards to select an option using the arrow keys. Choose Safe Mode with Networking and press Enter on your keyboard.

Step 4. Safe Mode with Networking will now launch on your PC.

Step 5. Press Windows key + R on your keyboard and hold. This will launch the Run tool.


Step 6. Go to this URL by copy-pasting it on the space and pressing Enter: https://errortools.com/download/advanced-system-repair/

Step 7. This will bring you to the website, where you can download the Advanced System Repair program. Wait until the installer finishes downloading to your PC. Install the software.

Step 8. After the program is finished installing, launch ASR to scan your system.


Step 9. Once the full scan is finished, select the Fix, Clean & Optimize option.


Method 6. Run Diskpart as Administrator

If you want to fix Diskpart failed to clear disk attributes on Windows, you will need to run Diskpart as Administrator. Whenever you will not log in to the computer as an administrator or fail to run Diskpart as Administrator, you will not be able to run the attribute disk clear read-only command.

So, if you want to switch user account to an administrator account and run the Diskpart command, you need to follow the below-mentioned steps that involve:

Step 1. Tap on the Windows icon, click on your username and select the Administrator option.


Step 2. Here, log in and switch to your Administrator account.
Step 3. Now, connect your locked or read-only device to the computer if it is an external storage device.
Step 4. Enter cmd in Windows Search Box and right-click on Command Prompt to open it as Administrator.
Step 5. Now, enter Diskpart and click the Enter button.
Step 6. Enter the commands listed below and hit the Enter button each time in order to clear the read-only state from your device.

Step 7. Enter Exit to close the Diskpart when the entire process is completed.

At the end of Step 7, you will note that the Diskpart failed to clear the disk attributes issue has been resolved, and you will now be able to open and make use of files on your target device again. And, if, in any case, the issue still persists, you can try to fix it by using the following method.

Method 7. Run Antivirus Software

The malware or virus infections in your PC can sometimes block you from accessing your drive flawlessly, thus making your drive showing up as read-only. So, if the viruses or malware are really causing the issue, then it's time to run Antivirus software and detect the virus, if any. In order to run antivirus software on your PC, you need to:

Step 1. Connect your read-only or locked external drive to the computer system.
Step 2. Download and run antivirus software on your PC.
Step 3. Now, enter the antivirus software and select to wipe and clean out all the suspicious malware and viruses from your device.

That's all! Now you're good to go and check if the external drive is now accessible or not. If the external drive is still not accessible and locked, you can switch to the next method to fix the issue.

Method 8. Check The Drive Space Usage and File Attributes

If none of the above-mentioned methods didn't solve the issue, you need to check the drive space usage and file attributes to fix it. So, it is essential for you to make sure that there is enough space in the drive, and you must disable the read-only attribute of files because sometimes the write protection issue may arise due to read-only attributes or space shortage. Here's how you can fix it!

Step 1. Go to Start Menu and click on the File Explorer icon.


Step 2. In the File Explorer window, go to the folder or file that you want to transfer to the external drive and right-click on it. Now, from the drop-down list, select Properties.


Step 3. Under the General tab, go to the Attributes option at the bottom and uncheck the box located just next to the Read-Only box.


Step 4. Finally, click on Apply and hit the OK button to save the changes and exit.


Diskpart is a powerful built-in tool created Windows so you can manage your disks and partitions on your own. But sometimes, you might encounter some errors while running this utility. With any of these solutions, you’ll surely find a fix to your Diskpart issues.

Recoverit author

Theo Lucia

chief Editor

Home > Resources > Windows Computer Solutions > How to Fix Diskpart failed to clear disk attributes in Windows