Quick Links

If your USB flash drive, SD card, or another drive isn't working quite right, "cleaning" the drive and removing its partitions is one possible solution. This can fix problems with a drive that can't be formatted or one that shows the wrong capacity.

Related: How to Manage Partitions on Windows Without Downloading Any Other Software

This trick also deletes partitions that you can't delete with normal tools, like the graphical Disk Management disk-partitioning tool built into Windows. The process we'll cover here completely erases the partition table from a disk, allowing you to set it back up again.

Warning: This process completely wipes the entire disk you select, so be sure you back up any important files first. You should also be very careful to specify the correct disk, or you could accidentally wipe the wrong one.

Step One: Launch a Command Prompt as Administrator

First, you'll need to launch a Command Prompt window as administrator. On Windows 10 or 8.1, right-click the Start button (or press Windows Key + X) and select "Command Prompt (Admin)."

Note: If you see PowerShell instead of Command Prompt on the Power Users menu, that's a switch that came about with the Creators Update for Windows 10. It's very easy to switch back to showing the Command Prompt on the Power Users menu if you want, or you can give PowerShell a try. You can do pretty much everything in PowerShell that you can do in Command Prompt---including the command we're using in this article---plus a lot of other useful things.

Related: How PowerShell Differs From the Windows Command Prompt

On Windows 7, open the Start menu and search for "cmd." Right-click the "Command Prompt" shortcut that appears and then choose "Run as Administrator."

Step Two: Use "diskpart" to Clean a Disk

We'll be using the diskpart command to clean the disk. Before continuing, be sure you've connected the USB flash drive, SD card, or whatever other drive you want to clean.

To launch the diskpart tool, type the following command at the Command Prompt and then press Enter:

diskpart

Notice that the prompt changes to "DISKPART>" to indicate you're now issuing commands to that tool.

Next, have diskpart list the disks connected to the computer by typing the following command and then pressing Enter:

list disk

Examine the output of the command to identify the number of the disk you want to clean. Be very careful here! If you select the wrong disk number, you'll clean the wrong disk and you could lose important data.

In the screenshot below, we can see that "Disk 0" is 238 GB in size and "Disk 1" is 14 GB in size. We know that our particular USB drive is 14 GB in size. This tells us that Disk 1 is the USB drive connected to the computer, and Disk 0 is the computer's internal system drive.

Related: How to Manage Partitions on Windows Without Downloading Any Other Software

If you have any trouble identifying the correct disk number, you can also fire up the Disk Management tool. It will show you the disk numbers along with the letters Windows has assigned it, making it easier to identify a particular disk.

When you know the disk number you want to select, type the following command, replacing # with the number of the disk you identified above. Again, be absolutely sure you have the right disk number.

select disk #

Now that you've selected the disk, any further commands you issue to the diskpart tool will be performed on the selected disk. To completely wipe the selected disk's partition table, type the following command and then press Enter. Remember, this command will completely wipe the disk, so be sure you have any important files backed up.

clean

You'll see a message stating that "DiskPart succeeded in cleaning the disk" if everything worked properly. You're now done. Close the Command Prompt window to continue.

Step Three: Partition and Format the Disk

You should now be able to initialize, partition, and format the disk like you normally would, using the graphical Disk Management tool built into Windows. You could also use the diskpart command to do this, but it's probably easier to use the graphical interface.

To launch Disk Management on Windows 10 or 8.1, right-click the Start button and select "Disk Management". On Windows 7, press Windows Key + R, type "diskmgmt.msc" into the Run dialog that appears, and press Enter.

You'll see the disk now has no partitions. Right-click the unallocated space and select "New Simple Volume" to create a partition on the disk and format it with your desired file system. By default, Windows will create a single partition that spans the entire drive.


If this method didn't work---for example, if you successfully cleaned the drive but it didn't appear to be functioning normally when you try to partition it, or if diskpart can't see the disk or clean it properly---it's possible the drive is physically damaged and no longer working properly. But "cleaning" the drive with diskpart is a solution that can bring back to life drives that would otherwise seem broken.