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.
This trick will also delete partitions that can’t be deleted with normal tools, like the graphical Disk Management disk-partitioning tool built into Windows. This process will completely erase the partition table from a disk, allowing you to set it back up again.
Warning: This process will completely wipe 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 disk.
Launch a Command Prompt as Administrator
First, you’ll need to launch a Command Prompt window as administrator. On Windows 10 or 8.1, you can simply right-click the Start button (or press Windows Key + X) and select “Command Prompt (Admin)”.
On Windows 7, you’ll need to locate the “Command Prompt” shortcut in the Start menu — you can just search for “Command Prompt” in the Start menu. Right-click the Command Prompt shortcut and select “Run as Administrator.”
Use diskpart to Clean a Disk
We’ll be using the diskpart command to do this. Before continuing, be sure you’ve connected the USB flash drive, SD card, or whatever other drive you want to clean to your computer.
To launch the diskpart tool, type the following command into the Command Prompt window and press Enter:
Have diskpart list the disks connected to the computer by typing the following command and pressing Enter:
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.
Once you know the disk number you want to select, type the following command, replacing # with the number of the disk you identified above.
Warning: Be very careful you specify the correct disk number! Enter the wrong disk number and you’ll end up blowing away everything on the wrong disk.
select disk #
The diskpart command has now selected the disk you specified. Any actions you perform will now be performed on the selected disk. To completely wipe the selected disk’s partition table, type the following command and press Enter.
Warning: This will erase all data on the selected disk! Be sure you have backups of the important data before continuing!
You’ll see a “diskpart succeeded in cleaning the disk” if everything worked properly. You’re now done. Close the Command Prompt window to continue.
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 simply physically damaged and is no longer working properly. But “cleaning” the drive with diskpart is a solution that can bring drives that would seem broken to most people back to life.