guide · static export
PC · usb

Wipe and Re-Partition a USB Stick with Diskpart

A stick with a broken partition table, a second partition from an ISO or the wrong filesystem is fixed in five diskpart commands. The only hard part is selecting the right disk.

by@guidox updated:10/31/26 time:15 min level:Beginner tested on:Windows 11 24H2 works on:Windows 10, Windows 11, Windows Server 2019 tools:Command Prompt as administrator, A USB stick
TL;DR

Confirm the **disk number** with **Get-Disk**, then in **diskpart** run **select disk**, **clean**, **create partition primary** and **format**. Never run clean before you have checked the size and bus type.

Before you start

Requirements

  • Admin rights
  • A USB stick you can erase
  • 15 minutes
Step by step

Instructions

01

Find the disk number and prove it

Letters change, disk numbers do not. Read the **size**, the **bus type** and the model, then unplug every other removable drive so the number cannot shift between commands.

Get-Disk | Select-Object Number,FriendlyName,Size,BusType,PartitionStyle
Get-Partition -DiskNumber 3 | Select-Object PartitionNumber,DriveLetter,Size
⚠ warning**clean** wipes the selected disk without a prompt and without a recycle bin. If the size does not match the stick in your hand, stop.
02

Start diskpart and select the disk

Select by number and confirm with **detail disk** before you type anything destructive. The output repeats the model and size, which is your second check.

diskpart
list disk
select disk 3
detail disk
03

Clean and create one primary partition

**clean** removes every partition and the boot records. One primary partition with the whole disk is what a normal data stick needs.

clean
create partition primary
select partition 1
active
assign
04

Pick the filesystem on purpose

**exFAT** has no 4 GB file limit and works on Windows and macOS. **FAT32** is needed for firmware and boot sticks but cannot hold a file over 4 GB — an install.wim has to be split then.

format fs=exfat quick label="USB"
:: or for a UEFI boot stick:
format fs=fat32 quick label="BOOT"
tip**quick** skips the surface check. Use a full format only when you suspect the stick itself, because it takes hours on a large drive.
05

Verify from outside diskpart

Leave diskpart and check that Windows sees a healthy volume with the filesystem you asked for. A RAW volume here means the format did not complete.

exit
Get-Volume | Where-Object DriveType -eq 'Removable' | Select-Object DriveLetter,FileSystem,FileSystemLabel,Size,HealthStatus
06

Reset the stick if it refuses to be written

Write protection comes from a physical switch, a policy or a firmware flag. **clear readonly** fixes the firmware flag; the other two have to be removed at the source.

diskpart
list disk
select disk 3
attributes disk
attributes disk clear readonly
attributes volume clear readonly
Troubleshooting

Common issues

clean fails with access denied

The disk is write protected or in use. Close Explorer windows on it, run the prompt elevated, and clear the readonly attribute as in step 6.

The stick does not appear in list disk

A dead controller or a loose port. Try another port and another machine before you assume the stick is gone.

The volume shows as RAW after the format

The format was interrupted or the stick has failing flash. Repeat create partition and format; if it happens twice, retire the stick.

Windows refuses files over 4 GB

That is the FAT32 limit. Reformat as exFAT or NTFS, or split the file with the tools Microsoft documents for install images.

FAQ

Frequently asked

Does clean destroy the data beyond recovery?

It removes the partition table, not the flash content. Data recovery tools can still read the blocks; overwrite them if the stick held secrets.

exFAT or NTFS for a stick?

exFAT for portability across operating systems, NTFS when you need permissions and compression and only use Windows.

How to undo this

There is nothing to restore — the previous partition table is gone. Recreate the old layout in diskpart, or write the image back that was on the stick before.

Changelog · 1 entry
  1. 2026-10-31
    First version
Interactive version: checklist, feedback, related guides →

Free · no account needed · tracks your progress