Home windows computer solutions Format USB CMD: How to Format USB Drive via Command Line 2026

How to Format a USB Drive Using CMD in Windows 2026

Ethan CarterEthan Carter
|Last Updated: March 14, 2026

Command Prompt gives you more control over USB formatting than File Explorer — including formatting drives that are write-protected or won't respond to the GUI.
This guide covers the exact diskpart and format commands, which file system to choose, and how to recover files with Ritridata if you format the wrong drive.

Formatting a USB drive via CMD (Command Prompt) is useful when File Explorer's format dialog fails, the drive is write-protected, or you need more control over the file system and allocation unit size. This guide covers the two main methods — the format command and diskpart — with exact commands for each scenario.

Part 1. Why Use CMD Instead of File Explorer?

SituationCMD Advantage
Write-protected USBdiskpart can remove write protection before formatting
USB won't respond to right-click Formatdiskpart forces formatting with lower-level access
Need specific allocation unit sizeformat command accepts /A: parameter
Need to convert MBR/GPT schemediskpart handles partition scheme changes
Batch formatting multiple drivesCMD scripting automates the process

For standard formatting without complications, File Explorer (right-click → Format) is faster and less risky.

⚠️ Important: CMD formatting commands do not ask for confirmation before erasing. Double-check the disk number in diskpart before typing any destructive command — formatting the wrong disk permanently erases its contents.

Part 2. Format a USB Drive Using Diskpart

Diskpart is a powerful Windows command-line disk partitioning tool. Use it when the standard format fails.

Step-by-step:

diskpart
list disk
select disk X
list partition
select partition 1
format fs=fat32 quick
exit

(Replace X with the USB drive's disk number from list disk)

💡 Tip: After list disk, identify your USB drive by its size — not by disk number alone. A 32 GB USB will show as approximately 29 GB in list disk. Never select a disk based on number alone; verify the size matches your USB drive before proceeding.

Common file system options in diskpart:

  • format fs=fat32 quick — FAT32 (max 32 GB for FAT32 in Windows, max 4 GB per file)
  • format fs=exfat quick — exFAT (recommended for drives over 32 GB used on Windows and Mac)
  • format fs=ntfs quick — NTFS (Windows-only read/write, full read on Mac)

Part 3. Remove Write Protection Before Formatting

If the USB drive is write-protected and refusing to format:

diskpart
list disk
select disk X
attributes disk clear readonly
clean
create partition primary
format fs=exfat quick
assign
exit

⚠️ Important: The clean command in diskpart removes all partitions and data from the selected disk. Confirm you have selected the correct disk number before running clean. This is the most destructive command in diskpart — it cannot be undone.

Part 4. Which File System to Choose

File SystemMax File SizeWindowsMacLinuxUse Case
FAT324 GBYesYesYesUniversal compatibility, older devices
exFAT16 EBYesYesYes (with extras)Large files, cross-platform
NTFS16 TBYesRead-onlyYesWindows-only, large files

💡 Tip: Use exFAT for any USB drive you plan to use on both Windows and Mac. It has no practical file size limit and is natively supported without additional software on both platforms. FAT32 is only recommended for very old devices (pre-2006 cameras, some TVs) that don't support exFAT.

🗣️ r/techsupport user on formatting via CMD: "File Explorer kept giving me an error formatting my USB. Used diskpart to select the disk, clean it, create a new partition, and format as exFAT. Took 5 minutes and worked perfectly."

🗣️ r/sysadmin tip on diskpart safety: "Always run list disk and verify the size before selecting a disk in diskpart. Formatting the wrong disk with a similar size is a surprisingly easy mistake that's impossible to undo."

Part 5. Recover Files If You Formatted the Wrong Drive With Ritridata

If you formatted the wrong disk by mistake, immediately stop using both drives — the formatted drive and the one you intended to format. Ritridata can scan a quickly-formatted drive and recover files from the sectors before new data overwrites them.

Step 1 — Select the accidentally formatted drive from the list

Step 2 — Run a safe scan — the drive is not further modified

Step 3 — Preview and recover your files to a separate drive

FAQ

How do I format a USB drive using CMD in Windows? Open Command Prompt as Administrator. Type diskpart, then list disk to identify your USB. Type select disk X (replace X with the disk number), then format fs=exfat quick to format it as exFAT with Quick Format.

What is the difference between format and diskpart format? The standalone format command formats an existing partition. diskpart gives you full disk control — you can clean the disk, create new partitions, and format them. Use diskpart when the standard format command fails or when you need to start with a clean disk.

Can diskpart format a write-protected USB drive? Yes — in diskpart, run attributes disk clear readonly after selecting the disk. This removes the read-only attribute. If write protection is hardware-based (physical switch on the USB), the attributes command will not help — check for a physical lock switch on the drive.

Is Quick Format the same in CMD as in File Explorer? Yes — format fs=exfat quick performs the same operation as checking "Quick Format" in File Explorer. Both rebuild the file system without overwriting file data, making recovery possible afterward if needed.

How do I check disk numbers in diskpart safely? Run list disk and look at the Size column. Match the size to your USB drive. A 64 GB drive will show approximately 59 GB. Always verify size before selecting — disk numbers change depending on which drives are connected.

Can I format only part of a USB drive using CMD? Yes — using diskpart, you can create multiple partitions on a USB drive and format each separately. Create partitions with create partition primary size=X (where X is MB) before running the format command on each.

References