At times, when your hard drive, USB pen drive, or SD card is set to read-only or has write-protection, you would need to run the Diskpart utility with the command "attributes disk clear readonly" to remove the read-only status from your device.

However, some users report that Diskpart fails to clear disk attributes for unspecified reasons. On this page, we will delve into this issue and provide effective solutions to help you resolve it, restoring your drive and data to a usable state.

Overview of "Diskpart Failed to Clear Disk Attributes"

In this part, you will learn:

    1. What is the "Diskpart failed to clear disk attributes" error? 2. Why is Diskpart not functioning properly?

Error: Diskpart failed to clear disk attributes is an error message that appears when executing the read-only clear command using Diskpart. The error occurs as follows:

You execute the **attributes disk** command in Diskpart to examine the status of your inaccessible device, and you notice the "Current Read-only State: Yes" and "Read-Only: Yes" indications. Consequently, you type **attributes disk clear read-only** in Diskpart in an attempt to remove the read-only attribute.

However, for some unknown reasons, Diskpart fails to execute the operation. It pops up an error message, stating "Diskpart failed to clear disk attributes," as shown below:

Diskpart failed to clear disk attributes

Why does Diskpart fail when running the "attributes disk" command? Here's a list of reasons that might explain why Diskpart failed to perform the operation on your devices:

  • The physical switch on the USB, external hard drive, or SD card is locked.
  • You did not run Diskpart with Administrator privileges.
  • Your device has bad sectors or a corrupted file system.
  • Your device has turned into a RAW format.
  • A virus or malware has locked your device.

If your hard drive, USB, external hard drive, or SD card has any of the issues mentioned above, Diskpart cannot clear the read-only status. So, how do you remove the read-only attribute from your devices in Windows 10/8/7? Keep reading to find the optimal solution.

How to Resolve the 'Diskpart Failed to Clear Disk Attributes' Issue [8 Solutions]

Applies to: Solve and remove read-only attributes from your locked or write-protected internal/external hard drive, USB flash drive, SD card, and other devices.

Regardless of how you encountered the "Diskpart clear read-only not working" issue, here you can find 8 comprehensive solutions to resolve the problem:

    1. #1. Turn Off Device Physical Lock Switch
    2. #2. Run Diskpart as Administrator
    3. #3. Check and Fix Disk Error
    4. #4. Format Target Drive
    5. #5. Remove Write Protection Using Regedit.exe
    6. #6. Use Regedit.exe Alternative
    7. #7. Run Diskpart Clean Command
    8. #8. Run Antivirus Software

Please note that to prevent unintended file loss, we recommend attempting Methods 1, 2, and 3 first, as Methods 4, 5, 6, 7, and 8 might result in file loss on your device. Additionally, if you experience file loss during the process, consider using reliable data recovery software like Data Recovery Wizard for assistance.

Let's begin resolving this issue and remove the read-only attributes from your device right away.

Method 1: Turn Off the Physical Lock Switch

When encountering the "Diskpart failed to clear disk attributes" issue while using Diskpart to clear the read-only disk attributes, you can first inspect the physical switch on your device.

Step 1. Locate the physical switch on the hard drive, USB pen drive, or SD card.

Step 2. Check if the switch is on the Lockside.

Step 3. If yes, turn it off.

Fix Diskpart failed to clear disk attributes issue - turn off the physical Write protection switch

Step 4. Then run the Diskpart clear read-only command and see if it works properly.

Method 2: Run Diskpart as an Administrator

Note that if you didn't log in to the computer as an administrator or fail to run Diskpart with administrative privileges, you won't be able to execute the "attribute disk clear readonly" command.

Here's how to switch to an administrator account and execute the Diskpart command: 1. Press the Windows key + X on your keyboard. 2. From the menu that appears, click on "Control Panel." 3. In the Control Panel, select "User Accounts" or "User Accounts and Family Safety" (depending on your Windows version). 4. Choose "Manage another account" or "Add or remove user accounts." 5. Locate the administrator account and click on it. 6. Click "Switch User" or "Sign out" to log out of your current user account. 7. Sign in to the administrator account using the appropriate credentials. 8. Once logged in, click on the Start button, type "cmd" in the search bar, and press Enter. 9. A User Account Control prompt may appear. Click "Yes" to confirm that you want to run Command Prompt as an administrator. 10. In the Command Prompt window, type "diskpart" and press Enter. 11. Now, type "list disk" and press Enter to view a list of available disks. 12. Proceed with the additional Diskpart commands you need to execute for your specific task. Remember that Diskpart is a powerful tool, so exercise caution when making changes to your disks.

Step 1. Click the Windows icon, then click your username and select "Administrator".

Log in and switch to your administrator account.

Switch user account

Step 2. Connect your read-only or locked device to your computer if it's an external storage device.

Step 3. Type cmd in the Windows Search box, then right-click Command Prompt and open it as "Administrator".

Step 4. Type diskpart and press Enter.

Step 5. Type the following commands one by one and press Enter after each to remove the read-only state from your device:

    1. list disk
    2. select disk 0 (Replace 0 with the disk number of your problematic drive.)
    3. attributes disk clear readonly

Step 6. Type exit to close Diskpart when the process is complete.

After this, you will notice that the "Diskpart failed to clear disk attributes" issue has been resolved. You should now be able to access and utilize your files on the target drive once again.

Method 3: Check and fix disk errors

Sometimes, when your storage device has bad sectors or file system errors, it becomes non-editable. Consequently, the Diskpart command line will not execute successfully on the device.

Hence, it recommends running a reliable utility to scan and repair existing corruption or bad sectors on the drive. A dependable partition software like EPM Pro with its Check File System feature can be of assistance.

Upon resolving the device errors, attempt to open the device and check if it remains write-protected or read-only. If it does, return to Method 2 and execute the Diskpart command lines to eliminate the issue.

Method 4: Format RAW Target Drive

Note that another error that might prevent Diskpart from executing the attribute disk clear readonly command is if your drive or external storage device becomes RAW.

To resolve this issue, you can directly format it into a recognized file system such as NTFS, FAT32, etc. Follow these steps: 1. Connect the storage device (e.g., USB drive or external hard drive) to your computer. 2. Open File Explorer on your Windows PC or Finder on a Mac. 3. Locate the connected storage device, usually displayed under "Devices" or "External Devices" in File Explorer or "Devices" in Finder. 4. Right-click on the device and select "Format" from the context menu on Windows, or choose "Erase" on a Mac. 5. In the Format window on Windows: - Select the desired file system (e.g., NTFS for general use or FAT32 for compatibility across different devices). - Choose a name for the drive if needed. - Ensure "Quick Format" is checked. - Click "Start" to begin formatting. On a Mac in the Erase window: - Choose a format (e.g., ExFAT for compatibility with both Windows and Mac, or MS-DOS (FAT) for older systems). - Enter a name for the drive. - Click "Erase" to proceed. 6. A warning message will appear, reminding you that formatting will erase all data. Confirm the action when prompted. 7. Wait for the formatting process to complete, then safely eject the device and re-insert it. It should now be recognized by your computer in the correct format. Remember that formatting will delete all data on the device, so ensure you have backups of any important files before proceeding.

If it's an external hard drive or USB, plug it into your PC first.

Option 1. Format RAW Drive using a Formatting Tool

With its Format feature, the tools Partition Master tool simplifies the process of formatting various devices to NTFS, FAT32, exFAT, EXT, and more with just a few clicks.

Option 2. Format RAW Drive Using Disk Management This option involves using the built-in Disk Management utility in Windows to format the RAW drive. Follow these steps: 1. **Access Disk Management:** - Press `Windows + X` on your keyboard and select "Disk Management" from the menu. - Alternatively, right-click on the Start button, and choose "Disk Management." 2. **Find the RAW Drive:** - In the Disk Management window, locate the RAW drive, which is usually indicated by an unallocated space or a drive without a letter assigned. 3. **Format the RAW Drive:** - Right-click on the RAW drive and select "Format." - A Format dialog box will appear. 4. **Set Format Options:** - Choose a file system, such as NTFS (default for most users), FAT32, or exFAT, depending on your needs. - Set the allocation unit size to the default (usually recommended). - Optionally, you can provide a label for the drive. - Make sure the "Quick Format" option is checked. 5. **Start Formatting:** - Click "OK" to begin the formatting process. This may take some time, especially if the drive has a large capacity. 6. **Confirm Formatting:** - A warning message will appear, informing you that all data on the drive will be erased. Click "OK" to proceed if you are sure. 7. **Wait for Completion:** - The formatting process will now start, and once completed, the drive will be formatted with the selected file system. Remember that formatting will erase all data on the drive, so ensure you have backed up any important files before proceeding.

Step 1. Right-click "This PC" or "My Computer" and click "Manage", then click "Disk Management".

Step 2. Right-click on the RAW drive and select "Format." Click "Yes."

Select Disk Management and choose Format

Step 3. Name the drive and choose the file system as "NTFS" or "FAT32". Click "OK".

convert to fat32 using disk management

Step 4. Now, open the drive and check if it's still in read-only mode.

If yes, proceed with the steps in Method 2 to resolve the read-only issue.

Method 5: Remove Write Protection using Regedit.exe

If your device is locked or displaying the error message "disk is write-protected" on Windows 10, you can use Registry Editor to remove the protection and unlock your device for usage. Follow these steps: 1. **Open Registry Editor**: Press the Windows key + R on your keyboard to open the Run dialog box. Type "regedit" and press Enter to launch Registry Editor. 2. **Back up Registry**: Before making any changes, it's crucial to create a backup of your Registry. Click on 'File' in the top-left corner, then select 'Export'. Choose a save location and give the file a name. Make sure to check 'All' under 'Export range' and click 'Save'. 3. **Navigate to the Key**: In the left pane of Registry Editor, navigate to: `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies` If the 'StorageDevicePolicies' key doesn't exist, right-click on 'Control', select 'New', and then 'Key'. Name the new key 'StorageDevicePolicies'. 4. **Create a New DWORD Value**: In the right pane of the 'StorageDevicePolicies' key, right-click, choose 'New', and then 'DWORD (32-bit) Value'. Name this value 'WriteProtect'. 5. **Edit the DWORD Value**: Double-click the newly created 'WriteProtect' DWORD, and set its 'Value data' to '0'. Click 'OK' to save the changes. 6. **Reboot your Computer**: Close Registry Editor and restart your computer for the changes to take effect. 7. **Check the Device**: After rebooting, your device should no longer be write-protected, and you should be able to use it normally. Remember that editing the Registry can be risky, so make sure you follow these steps carefully and have a backup before proceeding.

Step 1. Connect the read-only device to your PC.

Step 2. Press the Windows + R keys to open the Run box. Type regedit and click "OK".

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

Step 4. Click the Write Protection icon, and set the Value data to "0". Click "OK".

Fix Diskpart failed to clear disk attributes issue using Regedit.exe

Method 6: Regedit.exe Alternative - Write-Protection Removal Tool

If you don't consider yourself a pro-computer user and you're not familiar with command lines, don't worry. There are graphical-based solutions to help you remove write-protection from your hard drives, USB drives, and even SD cards.

CleanGenius is one of these tools that helps you fix the aforementioned issues on your drives without knowing a thing about command-line.

Here's a simple step-by-step guide on how to utilize this tool to resolve your issues:

Step 1: DOWNLOAD and install the CleanGenius tool (free) on your computer.

Step 2: Run CleanGenius on your PC, select Optimization and choose the Write Protection mode.

disable write protection

Step 3: Select the device that is write-protected and click on "Disable" to remove the protection.

Disable Write Protection on storage devices.

Method 7: Execute the Diskpart Clean Command

Another easy way to unlock a write-protected or locked device with a "read-only" state is by running the clean command in Diskpart. However, this will result in the loss of all partitions and data on your drive.

So, please consider carefully before proceeding to the next steps.

Step 1. Connect your removable device to your computer first.

Step 2. Type cmd in the search box, then right-click Command Prompt and select "Run as Administrator."

Step 3. Type diskpart and press Enter to launch it.

Step 4. Type the following command and press Enter after each one.

The following commands will clean the device and forcefully remove the read-only state:

    Translate into English:
  • list disk
  • select disk 2
  • clean

Clean disk

Please note that your drive is now without any partitions, and all its contents have been completely removed. If you had valuable files saved on it, you can seek assistance from reliable data recovery software like tools Data Recovery Wizard to retrieve them.

Step 5. Now, you can create a new partition on your device by using the following command lines, which will make it functional again:

    1. list disk
    2. select disk * (* represents the disk number)
    3. create partition primary size=* (* means the partition size in MB.) 
    4. assign letter=* (* represents Choose a drive letter not already being used.)
    5. format fs=ntfs quick
    6. exit

Create new volume after cleaning disk

Now, your drive is in a good and healthy state, allowing you to save and store new data on it once again.

Method 8: Run Antivirus Software

Occasionally, viruses or malware infections might restrict access to your drive, causing it to display as read-only. To resolve this problem, you can also seek assistance from antivirus software:

Step 1. Connect your read-only or locked drive to the PC.

Step 2. Install and run antivirus software on your computer.

Step 3. Choose to clean and remove any suspicious viruses or malware from your drive.

Now, you can proceed to check if the drive is accessible and usable once again.

After fixing all possible disk errors, proceed to use Diskpart to remove the read-only attribute from the disk, and then check if the issue is resolved.

In conclusion

On this page, we delve into the "Diskpart failed to clear disk attributes" error and discuss why Diskpart might not be effective in resolving this issue. Additionally, we have compiled 8 dependable solutions to assist you in successfully fixing the disk read-only error, enabling you to use your drive for saving data once again in Windows 10/8/7.

Please note that your drive data might be lost during the process of using these methods. Hence, ensure you have a reliable data recovery software to rely on.

Additionally, we advise you to maintain your drive's health by promptly checking and fixing errors with tools like Partition Master, eliminating viruses with anti-virus software, and backing up all important data beforehand.