While formatting a USB drive through the Windows File Explorer is easy, sometimes it just doesn’t work. You might encounter errors, see the wrong capacity, or the drive might not even show up at all. In these cases, the Command Prompt (CMD) and its powerful Diskpart utility are your best tools to force a format and restore your drive to working order.
This guide will walk you through the exact steps to format a USB drive using CMD. While the process is powerful, it is also unforgiving. One wrong command can erase data from the wrong drive. I’ve used this method many times to fix stubborn drives, and the key is to be slow, careful, and precise. Follow these steps exactly to do it safely.
The Most Important Step: Back Up Your Data!
Warning: This process will permanently erase everything on the USB drive. Before you begin, check if you can access the drive on any computer and back up any important files. Once you use the clean command, there is no going back.
When Should You Use CMD to Format?
- When the standard Windows format tool fails with an error.
- When the USB drive is showing the incorrect size or capacity.
- When the drive is corrupted and not accessible through File Explorer.
- To remove stubborn write protection that other methods can’t fix.
Step 1: Open Command Prompt as an Administrator
To use Diskpart, you need administrative privileges.
- Click the Start Menu or press the Windows key.
- Type cmd.
- Right-click on Command Prompt in the search results and select Run as administrator.
- A User Account Control window will pop up. Click Yes.
You will now be looking at a black Command Prompt window.
Step 2: Launch the Diskpart Utility
Diskpart is the command-line tool that lets you manage your computer’s drives.
- In the Command Prompt window, type the following command and press Enter:
- diskpart
- Your prompt will change to DISKPART> to show that you are now inside the utility.
Step 3: Identify Your USB Drive
This is the most critical step of the entire process. You must correctly identify your USB drive to avoid erasing one of your computer’s main drives.
- In the DISKPART> prompt, type the following command and press Enter:
- list disk
- A list of all the disks connected to your computer will appear. They will be labeled Disk 0, Disk 1, and so on.
- Carefully identify your USB drive by looking at the Size column. For example, if you have plugged in a 32 GB USB drive, it will show a size slightly less than that (e.g., 28 GB or 29 GB). Your computer’s main hard drive (C:) will likely be much larger and is almost always Disk 0.
In the example below, Disk 2 is a 14 GB USB drive.
Disk ### Status Size Free Dyn Gpt
——– ————- ——- ——- — —
Disk 0 Online 476 GB 0 B *
Disk 1 Online 931 GB 0 B *
Disk 2 Online 14 GB 0 B
Step 4: Select and Clean the Drive
Once you are 100% certain which disk is your USB drive, you need to select it.
- Type the following command, replacing # with the number of your USB drive, and press Enter:
- select disk #
- For our example, we would type select disk 2. Diskpart will confirm with the message “Disk 2 is now the selected disk.”
- Now, to erase all existing partition and volume information from the drive, type the clean command and press Enter:
- clean Diskpart will work for a moment and then display “DiskPart succeeded in cleaning the disk.”
Step 5: Create a New Partition
With the drive now completely blank, you need to create a new partition to hold data.
- Type the following command and press Enter:
- create partition primary Diskpart will confirm that it has succeeded in creating the specified partition.
Step 6: Format the Partition
Now it’s time to format the new partition with a file system. This is where you choose the format type.
- Type the following command and press Enter:
- format fs=ntfs quick Let’s break this command down:
- format fs=: This is the command to format the selected partition.
- ntfs: This specifies the file system. You have three main choices:
- NTFS: The modern, standard file system for Windows. Best for larger drives used exclusively with Windows PCs.
- FAT32: The most compatible file system. It works with Windows, macOS, and Linux, but it cannot handle individual files larger than 4 GB. Use this for maximum compatibility.
- exFAT: A modern replacement for FAT32 that does not have the 4 GB file size limit. It’s a great choice for cross-platform use with large files.
- quick: This performs a quick format. It’s much faster and is fine for most situations. If you omit this, Diskpart will perform a full format, which can take a very long time on large drives. Diskpart will show a percentage progress and will notify you when it has successfully formatted the volume.
Step 7: Assign a Drive Letter and Exit
Finally, you need to assign a drive letter to make the USB visible in File Explorer.
- Type the following command and press Enter:
- assign Diskpart will automatically assign the next available drive letter (e.g., E: or F:).
- You are now finished. To exit the Diskpart utility, type exit and press Enter.
- To close the Command Prompt window, type exit again and press Enter.
Your USB drive is now freshly formatted, clean, and ready to use.