How to Clean and Format a USB Drive with Diskpart
Download nowdiskpart'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
- 1Open an elevated Command Prompt and type diskpart, then Enter.
- 2Type list disk and note the disk number matching your USB drive's size.
- 3Type select disk N (replace N with that number).
- 4Type clean to wipe the partition table.
- 5Type create partition primary.
- 6Type select partition 1.
- 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).
- 8Type assign to give it a drive letter.
- 9Type exit to close diskpart.
FAT32 vs NTFS for USB drives
| File system | Best for |
|---|---|
| FAT32 | UEFI boot media, maximum compatibility, 4GB file size limit |
| NTFS | Files larger than 4GB, Windows-only use |
| exFAT | Large 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.
Related pages
- DiskpartOverview of the diskpart cmd tool and its core disk and partition commands.
- RufusLightweight open-source bootable USB creation tool from Akeo/Pete Batard.
- Create Bootable USB (Windows 11)Step-by-step comparison of Rufus, Media Creation Tool, and manual DiskPart methods.
- FAT32 Format ToolExplains the Windows 32 GB FAT32 formatting limit, exFAT as the modern alternative, and diskpart/GUI tools that bypass it.