How to Clean and Format a USB Drive with Diskpart

Download now

diskpart's clean command completely wipes a USB drive's partition table, which is useful for fixing corrupted flash drives or preparing one for a fresh bootable image.

Updated August 9, 2026 · PC Utility Hub Editorial Team

Before you start

Back up anything on the USB drive you want to keep; clean does not ask for confirmation.

Warning: The 'clean' command permanently erases all data and the partition table on the selected disk. Double-check the disk number with 'list disk' — comparing it against the drive's size in the list — before selecting it, since selecting the wrong disk will wipe your main hard drive instead of the USB stick.

Step-by-step commands

  1. 1Open an elevated Command Prompt and type diskpart, then Enter.
  2. 2Type list disk and note the disk number matching your USB drive's size.
  3. 3Type select disk N (replace N with that number).
  4. 4Type clean to wipe the partition table.
  5. 5Type create partition primary.
  6. 6Type select partition 1.
  7. 7Type format fs=fat32 quick (use ntfs quick instead if the drive needs files over 4GB, or if it won't be used for BIOS boot).
  8. 8Type assign to give it a drive letter.
  9. 9Type exit to close diskpart.

FAT32 vs NTFS for USB drives

File systemBest for
FAT32UEFI boot media, maximum compatibility, 4GB file size limit
NTFSFiles larger than 4GB, Windows-only use
exFATLarge files with broad cross-platform compatibility, no journaling

When to use Rufus instead

If the goal is creating a bootable Windows installer, tools like Rufus or the Media Creation Tool automate partitioning and formatting correctly for UEFI or legacy BIOS boot. Use diskpart directly when you just need to wipe and reformat a drive for general storage, or when troubleshooting a USB drive that Windows won't format normally.

Frequently asked questions

What if diskpart clean fails with 'access denied'?
Make sure Command Prompt is running as Administrator and that the drive isn't write-protected (check with a physical lock switch on some USB drives).
Can I use diskpart to make a bootable USB directly?
You can prepare the partition (clean, create partition primary, active, format, assign), but you still need to copy Windows installation files or use a tool like the Media Creation Tool to make it bootable.
Does clean securely erase the data?
The basic clean command removes the partition table but doesn't overwrite all data sectors; use 'clean all' for a full zero-fill wipe of the entire drive.