What is DiskPart and Why Use It?
If your USB flash drive is suddenly unreadable, shows the wrong storage capacity, or throws a “Windows was unable to complete the format” error, the drive’s file system or partition table might be corrupted. Before throwing the drive away, you can often revive it using a built-in Windows command-line tool called DiskPart.
DiskPart bypasses the standard Windows graphical interface and forcefully wipes the drive clean, allowing you to create a fresh, healthy partition. Warning: This process will permanently erase all data currently on the USB drive. Proceed only if you have already backed up your data or if the data is unrecoverable anyway.
Step 1: Open the Command Prompt as Administrator
You must run DiskPart with administrative privileges.
- Click the Start button (or press the Windows key).
- Type cmd into the search bar.
- Right-click on Command Prompt and select Run as administrator.
- Click Yes on the User Account Control prompt.
Step 2: Identify Your USB Drive
You need to find the correct disk number for your USB drive to avoid accidentally erasing your computer’s main hard drive.
- In the Command Prompt window, type
diskpartand press Enter. You will see the prompt change toDISKPART>. - Type
list diskand press Enter. - A list of all connected drives will appear. Identify your USB drive by looking at the Size column. Note the disk number (e.g., Disk 1, Disk 2).
Step 3: Clean the Drive
Now we will select the corrupted drive and wipe it clean.
- Type
select disk X(replace X with the number of your USB drive from the previous step) and press Enter. You should see a message saying “Disk X is now the selected disk.” - Double-check that you have selected the correct disk.
- Type
cleanand press Enter. This command removes all formatting and partition information from the drive. It should only take a few seconds, and you will see a success message.
Step 4: Create a New Partition and Format
With the drive wiped clean, it’s time to create a new partition so Windows can use it again.
- Type
create partition primaryand press Enter. - Type
select partition 1and press Enter. - Type
activeand press Enter (this step marks the partition as active). - Next, we need to format the drive. For most modern USB drives, the exFAT file system is best as it works on both Windows and Mac. Type
format fs=exfat quickand press Enter. (If you prefer NTFS, useformat fs=ntfs quickinstead). - Once the format reaches 100%, type
assignand press Enter to give the drive a drive letter (like E: or F:). - Type
exitand press Enter to leave DiskPart, and close the Command Prompt window.
Your USB flash drive should now appear normally in Windows File Explorer and be ready for use.