Diskpart is an inbuilt Windows utility that users can employ to clean a disk, format a drive, or convert a disk for free. However, due to certain errors, Diskpart might fail to work properly at times. If the Diskpart command is not executing your commands, don't worry.

You can try the fixes provided on this page to get Diskpart back to normal, or opt for a Diskpart alternative to address the issue yourself:

American English translation: The quick brown fox jumps over the lazy dog.

Solutions That Work Step-by-Step Troubleshooting
Solution 1: Reconnect the Target Device to Your Computer Step 1: Unplug the USB or SD card from your computer; Step 2: Reconnect the target device to your computer...Full Steps
Solution 2: Check If the Drive Is in Use or Locked Step 1: Keep the target device connected to your computer and open File Explorer; Step 2: Try to open the device...Full Steps
Solution 3: Unlock the Drive, Remove Write Protection

#1. Unlock External USB/SD Card: Properly connect the external USB or SD card to your computer...Full Steps

#2. Remove Read-Only Status from the Device: Keep the device properly connected to your computer...Full Steps

#3. Remove Write Protection via Registry Key Editing: Connect the write-protected device to your computer...Full Steps

#4. Decrypt the Device with Third-Party Tools: Please note that if your hard drive, USB, or SD card is...Full Steps

Solution 4: Use a Free Disk Partition Tool to Clean the Disk/USB/SD Card (BitWiper) Step 1: Open the BitWiper tool and select "Erase Disk"; Step 2: Choose the external (or USB, SD, memory) hard drive you want to erase...Full Steps
Solution 5: Run Diskpart Clean Command to Clean the Drive/USB/SD Card Step 1: Connect the device to your computer; Step 2: Press Windows + R keys, type cmd, and hit Enter to open Command Prompt...Full Steps

Among the solutions, the BitWiper tool can help you easily wipe your USB, SD card, or drive.

"Error: Failed to clean up disk partitions"

Hello, do you know how to clean an entire disk or USB drive when the 'clean' command in Diskpart doesn't work on Windows 10? I intended to use Diskpart to wipe my external hard drive and erase all data, but it didn't work.

Instead, it prompts an error message, warning “DiskPart encountered an error: Access is denied……”. How can I fix this error? Are there any other DiskPart alternatives that can help me with this issue?

Diskpart not working - Access is denied

Are you also getting the same error on your computer? You were trying to format or clean a hard drive, USB flash drive, or SD card using Diskpart, but the Command Prompt gives you an error message that says Diskpart has encountered an error?

So why does Diskpart not work? Usually, the Diskpart not working issue is caused by the following reasons:

  1. 1. The drive is being used or accessed by another program.
  2. 2. The USB or SD card is locked or set to read-only.
  3. The hard drive is encrypted by a third-party encryption tool.

If your device is experiencing any of these issues, Diskpart will be unable to execute any formatting or disk wiping commands. For the solutions to these problems, refer to the next section where you'll find all the detailed steps below.

How to Fix the "Diskpart Clean Not Working" Error

Applies to: Fixes the issue where the Diskpart clean command fails or is unable to clean the disk in Windows 10, 8.1, 8, or 7 operating systems.

When Diskpart is not working or you can't format or clean a disk, try these 5 solutions immediately to fix the Diskpart not working issue on your computer. Then, you can format or clean a drive, USB, or SD card by yourself.

Solution 1: Reconnect the target device to your computer

Sometimes, when your hard drive or external USB, SD card is not properly connected to the computer, Diskpart won't execute any formatting or cleaning commands. Hence, your best bet is to reconnect the device:

Step 1. Eject the USB drive or SD card from your computer.

If it's a hard drive, connect it back to your computer with its SATA data and power cables.

Step 2: Reconnect the target device to your computer.

Step 3: Log in to your computer as an administrator.

Now proceed to Repair 2 to check whether the drive is currently locked or encrypted.

Fix 2: Check if the drive is in use or locked

< strong > Step 1. < /strong> Connect the target device to your computer and open a file explorer.

Step 2: Try to turn on the device and see if you can access all your data.

Step 3. Once you have access to the target device, proceed with cleaning the drive as explained in Solution 4 or Solution 5.

If you receive a message that a program or file is currently using your device, close the running program or open file. Then proceed to either Solution 4 or Solution 5 to perform disk cleanup.

If you receive the write protection notification, please follow the guide from Fix 3 below to remove or disable the write protection from your device first.

Fix 3: Unlock the drive and remove write protection

Please note that if the storage device is locked, encrypted, or write-protected, you won't be able to access or make any changes to the drive. Hence, the first step to fix the Diskpart not working error is to unlock, decrypt, and remove the write protection from the target disk.

You have four options:

Method 1: Unlock External USB/SD Card

Step 1: Connect your USB or SD card to the computer properly.

Step 2: Slide the USB or SD switch to the Off position.

Unlock SD card:

Unlock SD Card

Unlock USB:

Unlock USB

After that, you can run the Diskpart clean command to format your USB drive or SD card. As an easier option, you can use the Partition Master tool mentioned in Fix 4.

Solution 2: Remove the read-only status from the device

A common issue is when a device appears as read-only, which prevents Diskpart from cleaning or formatting the storage device. If your disk shows as read-only in Disk Management or indicates that it's read-only, follow these steps to clear the status and make the drive accessible again:

Step 1: Make sure your device is connected to your computer correctly.

Step 2. Press Windows + R, type cmd, and press Enter to open the Command Prompt.

Step 3: Type the following commands one by one in the terminal, and press Enter after each one to remount the device as read-write:

    • diskpart
    • list disk
    • select disk #
    • attributes disk clear readonly
    These are commands used in the Windows Command Prompt for managing disks. Here's a brief explanation of each: 1. **diskpart**: This command starts the Diskpart utility, which allows you to interact with disk storage devices on your system. 2. **list disk**: After launching Diskpart, this command displays a list of all the disks available on your computer. 3. **select disk #**: Here, replace '#' with the number of the disk you want to work with. This command selects the specified disk for further operations. 4. **attributes disk clear readonly**: This command removes the read-only attribute from the selected disk, if it has that attribute set. This is necessary before making any write operations or changes to the disk.

Please replace # with the disk number of your target device.

Step 4. When the process is complete, type exit to close the terminal.

Remove the write protection from the device

Method 3: Remove write protection by editing a registry key

When a storage device is write-protected, you can remove the write protection by editing a registry key, following these steps:

Step 1: Connect the read-only device to your computer.

Step 2. Type regedit in the Run dialog box, and click OK to open the Registry Editor.

Step 3. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies.

Step 4. Double-click on the “WriteProtect” key and change its value to “0”. Click “OK” to finish the setup.

Click “Change registry key to remove write protection” Change registry key to remove write protection

After that, exit the Registry Editor and restart your computer. You should be able to access the drive and clean it with the “Diskpart clean” command.

Remove Write Protection Tool

If you don't consider yourself very computer-savvy or comfortable with the command line, don't worry – there are graphical tools that can help you unprotect your hard drive, USB drive, or even your SD card.

CleanGenius is one such tool that can help you fix these issues on your disk, without having to resort to the command line.

This is a simple and easy-to-follow guide on how to use this tool to address your concerns:

Step 1: Download and install CleanGenius (free) on your computer.

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

Disable write protection

Step 3: Select the write-protected device and click on “Disable” to remove the protection.

Disable write protection from the storage device

#4. Use third-party tools for decryption

Keep in mind that if your hard drive, USB, or SD card is encrypted with third-party software or a program, you'll need to use the encryption tool to decrypt the drive.

Solution 4: Clean up Disk/USB/SD Card with Free Alternative to Diskpart

Best for:  Beginner and all-level Windows users;

Keep in mind that if you're looking for an all-in-one disk-cleaning tool, Diskpart may not be the best choice; it can be a bit complex, especially for Windows novices.

Here, we recommend you try the free disk cleaner – BitWiper. It is equal to diskpart in wiping files, cleaning and erasing data from USB, SD card or hard drive.

Now follow these steps to clean up your disk, USB, or SD card:

Step 1: Launch the BitWiper tool and select “Wipe Hard Drive” option.

Wipe External Disk 1

Step 2: Select the external (or USB, SD card, or flash) drive you want to wipe, then click “Next.”

Important: Make sure you have selected the correct external drive. This action cannot be undone.

Wipe external drive 2

Step 3: Choose an erasing method according to your security level and erasing speed, then click “Next”.

Wipe external hard drive 3

Step 4: Acknowledge the warning and select “Clear.”

Wipe External Disk 4

Step 5: Wait for the process to complete.

Wiping Complete

Fix 5: Run Diskpart Clean command to clean the drive/USB/SD card

Lastly, you should have fixed all errors that prevented Disk Management from running on your system drive or external storage device. You can then run the Disk Cleanup command within Disk Management to get it working normally again:

Use the Diskpart Clean command to wipe the disk:

Step 1: Connect your device to your computer.

Step 2: Press Windows + R simultaneously, type cmd, and press Enter to open the Command Prompt.

Step 3. Type each of the following disk-cleaning commands, pressing Enter after each:

    • diskpart
    • list disk
    • select disk #
    • clean or clean all

Please replace # with your drive letter.

"Cleans" refers to removing all the contents of the drive, but the files can be recovered.

"Clean all" means wiping your drive, and both partitions and data will be gone for good.

Step 4. Type exit to close the window.

Use Diskpart to clean the disk command

Conclusion

On this page, we explain the reasons behind the Diskpart clean not working error and provide a comprehensive solution to help you fix it. If you encounter this error, reconnect the drive and first remove the write protection.

Then, use the simplest alternative – AOMEI Partition Assistant Free – to wipe hard drive with Diskpart clean. It can easily erase all content on the hard drive with just a few simple clicks.

If you have more questions about Diskpart clean, you can refer to the questions and answers listed here. Hopefully, we've managed to clear your doubts.

People also ask about "Diskpart Clean"

1. Does Diskpart Clean Remove Data?

Please note that the Diskpart's clean command deletes all partitions and data on the target device. Hence, the data wiped can be recovered. So the answer is no.

The "Diskpart clean" command does not remove data. But the "Diskpart clean all" command does.

2. How long does Diskpart cleaning take?

According to most users and Partition Master experts, Diskpart clean is a very quick process. It takes only 1-2 minutes to wipe everything from the drive.

However, the Clean all command in Diskpart takes longer, about four to five minutes, because it removes all partitions on the target device and erases all saved files.

3. How to format a disk using the Diskpart command?

If you wish to format a hard drive, USB, or SD card using Diskpart, here's a simple guide for you:

    1. Connect the target disk to your computer. 2. Press Windows + R, type diskpart, and hit Enter. 3. Type list disk, then press Enter. 4. Type select disk # (replace # with the disk number), and press Enter. 5. Type format fs=ntfs quick or format fs=fat32 quick, then press Enter. 6. Type exit, and press Enter.

Read more: Format USB Flash Drive Using CMD.

Now you can use Diskpart to format a disk, wipe data from a hard drive partition, or change the file system on a USB/SD card, and so on.