Technical Anshu
Tutorials Blog
⌨️ Diskpart Method

Format a Pendrive with Diskpart Clean Command Step by Step

When the normal right-click format fails - RAW file system, wrong size, stubborn errors - the diskpart clean route rebuilds the pendrive from an empty partition table. It is the strongest format Windows has built in, and it demands respect: one wrong disk number erases the wrong drive.

✍️ Technical Anshu🪟 Windows 10 / 11⏱️ 7 minute read
🎥 The video runs this exact diskpart sequence live - watch the disk selection carefully

Diskpart works below the level of the normal format tool. Instead of repairing the existing partition, clean deletes the partition structure itself, and you then create a fresh partition and format it. That is why this route fixes drives that defeat the normal format - and why the disk-selection step matters more than every other step combined.

Administrator - Diskpart
DISKPART> list disk Disk ### Status Size Free Disk 0 Online 476 GB 0 B Disk 1 Online 29 GB 0 B DISKPART> select disk 1 Disk 1 is now the selected disk.
👆 Match the pendrive by SIZE - in this example the 29 GB disk is the pendrive, the 476 GB disk is the PC itself
1

When This Route Is the Right One

Use diskpart clean when the normal format fails with errors, the file system shows RAW, the drive reports a wrong smaller size because of a broken partition (common after making a bootable USB), or a previous format was interrupted. Do not use it as a first step for a simple write-protected message - try clearing the read-only attribute first, because clean erases everything while the attribute fix erases nothing.

2

Step 1 - Open Diskpart as Administrator

  1. Press Windows + R, type cmd, press Enter
  2. Type diskpart and press Enter
  3. Click Yes on the administrator permission prompt - a separate Diskpart window opens

Every command below is typed in that Diskpart window, one at a time, pressing Enter after each.

3

Step 2 - Identify Your Pendrive by Size

Type list disk. You will see every disk in the PC, including the internal drive Windows lives on. Find the pendrive by its capacity - a 32 GB pendrive shows about 29 GB, a 64 GB one about 58 GB. Selecting the wrong disk and running clean erases that disk completely, including your Windows drive. If two disks show the same size and you cannot tell them apart, unplug the pendrive, run list disk again, and note which number disappears. That is your disk.

4

Step 3 - The Full Command Sequence

  1. select disk X - X is your pendrive's number
  2. attributes disk clear readonly - removes a software lock if one is set
  3. clean - wipes the partition table
  4. create partition primary
  5. format fs=exfat quick - or fs=fat32 for small drives and old devices
  6. assign - gives the drive its letter
  7. exit

Each step should answer with a success message before you move to the next.

5

Step 4 - If a Command Fails, the Error Is the Diagnosis

Diskpart failures are informative. Write protected returning at the clean step means the controller lock - the drive is dying, not misconfigured. An I/O device error means the PC cannot reliably talk to the memory at all - try another port once, then accept the verdict. Access denied usually means the Diskpart window is not running as administrator. Read the error instead of retrying blindly; it is pointing at the real cause.

6

Step 5 - Prove the Rebuilt Drive Works

After assign, the pendrive appears in Explorer with its full size. Do not trust it yet. Copy a large file onto it - a video of a few hundred MB - then copy it back and compare, or simply play it from the drive. Eject with Safely Remove Hardware, reinsert, and confirm the file is still there. A drive that survives this test is genuinely rebuilt; a drive that corrupts the test file has a hardware problem no format will fix.

🔴 clean is instant and has no undo. There is no confirmation prompt and no recycle bin for a wiped partition table. The size check in Step 2 is not a formality - it is the whole safety of this method.

🎥 Watch the Full Video Guide

Watch the video for the live run of this sequence, including the list disk output and how the correct disk is chosen.

▶️ Watch Full Video
❓ Frequently Asked Questions

What is the difference between clean and clean all in diskpart?

clean only removes the partition table - fast, and the old data still physically sits on the memory until overwritten. clean all additionally writes zeros over every sector, which takes a long time on flash drives and wears them. For fixing a format problem, plain clean is enough.

I selected the wrong disk and ran clean. Is the data gone?

Stop immediately - do not create partitions or format that disk, and do not install anything on it. Partition recovery software can often rebuild the table if nothing new was written. Every write after the mistake lowers the chance, so the disk should stay untouched until recovery is attempted.

Quick format or full format in the format command?

For a rebuild after clean, quick is fine - the partition is brand new. Leave quick off only when you want Windows to scan every sector for damage, which is a diagnostic choice: a full format that stalls is itself evidence of dying flash.

This guide is based on the Technical Anshu pendrive format video • Stuck on a step? Ask in the video comments — you will get a reply 🙏