By Bryce / Last Updated August 21, 2019

Three types of Diskpart clean errors

Diskpart is a powerful Windows built-in utility that can help you to clean or format hard drive or USB drive with ease. In most cases, your hard drive or USB drive is able to be cleaned successfully under the help of Diskpart utility. But it is possible that the disk clean operation can’t be completed due to some errors and four common errors are listed below:

  • Diskpart has encountered an error: Access is denied.

  • Diskpart has encountered an I/O device error.

  • Diskpart has encountered an error: the media is write-protected.

Effectively fix differential errors occurred to Diskpart

Since three common Diskpart clean errors have been described in the previous paragraph, the corresponding solutions will be presented in following text.

Fix access denied error

When you receive the message that Diskpart has encountered an error: Access is denied, it means that your hard drive or USB drive is thought to be non-authorized or blocked.

Diskpart Clean Errror Access Denied

At first, you can check the System Event Log to get more information: Click “Start” icon > Enter “eventvwr”> Press “Enter” > Click “Windows Logs” > Click “System” and you can look for RED circles for Errors and Critical > Click one > choose “Details and General” Table to gain more detailed information. You may find that you didn’t run command prompt as administer. Then you can type “cmd” and press “Crtrl+Shif+Enter” to run command prompt as administer.

Fix I/O device error

If the Diskpart clean failed due to I/O device error, it is a lit bit complicated as this error could be caused by different events such as inappropriate connection, incompatible transfer mode, damaged hard drive or USB drive and so on. Therefore, what you should first is to check the connection of the device. Having confirmed that the device connection is OK, you can try to clean your device again with Diskpart. If the error message that Diskpart has encountered an I/O device error still appears, you might consider that whether the transfer mode for your device is correct or there is something wrong with the device. Take measures as the steps given below:

1. Press “Windows + R”, type “devmgmt.msc” to enter Device Manger.

2. Then click “IDE ATA/ATAPI controllers” to expand it.

3. Right click the channel where the device that you need to clean (usually, it is secondary IDE Channel) is connected

4. Choose “PIO Only” in the Transfer Mode Box for the proper device. Then, click “OK” and exit all windows.

5. Restart the Computer and observer whether the error is fixed.

If the problem still exists, you can try to check your device through the following steps: Double Click “This PC” > Right click the target drive and select “Properties” > Click on Tools Tab and click “Check” icon. Then the file system errors or bad sectors that cause I/O device error will be resolved.

Fix media write protected error

When the error message Diskpart has encountered an error: the media is write-protected appears, it means that your files on the device can’t be deleted or rewritten. You need to fix this error if you want to clean the drive.

If your device is USB drive that owns a physical read-only switch, you shall check the switch and put it to “OFF” side. Then, you can clean or format the USB drive with Diskpart. If not, you can skip this operation and try one or more solutions listed below:

Solution 1. Disable write protection via Diskpart

1. Press “Windows + R” and enter “diskpart” in the pop-up box. Then hit “Enter” key.

2. Type the following command and hit “Enter” in order:

“list disk”> “select disk n”, where n is the number of the target disk >“attribute disk clear readonly

Clear Read Only

Solution 2. Edit the registry

1. Press “Windows + R” and input “regedit”. Then, press “Enter”.

2. Navigate to the following paths:


3. Double click the “WriteProtect” Key and change the value to 0 in the pop-up window. Click “OK”.

Change Value to 0

Solution 3. Format drive via professional partition tool

When the two solutions are invalid, this error appears might due to corrupted file system. Under such circumstance, it is recommended to format the drive with a reliable third party partition tool AOMEI Partition Assistant Standard. It can format drive with corrupted file successfully within few steps to and very easy to handle.

Step 1. Right click the drive that you intend to format and choose “Format partition”.

Format Sd Card

Step 2. Determine the file system and cluster size. Click “OK”.

Choose File System

Step 4: Click “Apply” to complete the operation in the main user interface.



  • The time spending in formatting is depended on the data of your hard drive or USB drive.

  • It is avaliable to wipe hard drive as well via AOMEI Partition Assistant.


When Diskpart clean error appears, calm down and take corresponding measures according to different error message. Well, it is also a good choice to simply apply third party tool to clean hard drive or format it in Windows 10/8/7.