
Tip: If you lose data due to formatting a USB flash drive with Command Prompt, you can use data recovery software - such as Donemax Data Recovery to unformat the USB flash drive and get all deleted/formatted/lost data back.
PAGE CONTENT:
Formatting a USB flash drive is a common task that helps resolve errors, remove viruses, change the file system, or simply prepare the drive for new data. While Windows provides a graphical interface for formatting, using the Command Prompt (CMD) gives you more control over the process. This method is especially useful when the USB drive is corrupted, unrecognized, or experiencing issues that prevent formatting via standard methods.
In this detailed guide, we will walk you through the entire process of formatting a USB flash drive using CMD's diskpart tool. This detailed guide will assist you in safely and effectively formatting your USB, regardless of your level of experience.
Why Use CMD to Format a USB Flash Drive?
Using CMD to format a USB drive provides several advantages:
✔ Fix Corrupt Drives: CMD can clean and repair USB drives that don't work properly in File Explorer.
✔ Bypass Errors: If you get errors like "Windows was unable to complete the format," CMD can resolve them.
✔ Change File System: Easily switch between NTFS, FAT32, and exFAT file systems.
✔ Remove Partitions: CMD allows you to remove hidden or locked partitions.
✔ Quick & Efficient: CMD executes formatting much faster than GUI tools.
Prerequisites Before Formatting:
Before we begin, ensure you have the following:
- A USB flash drive connected to your computer.
- A Windows computer (Windows 11, 10, 8, or 7).
- Administrator access (CMD needs elevated permissions).
- Backup your data (Formatting will erase all files on the USB).
Steps to Format a USB Flash Drive with CMD (Command Prompt)
1. Open Command Prompt as Administrator
To format your USB, you need to run Command Prompt with administrative privileges:
- To run as administrator, enter Win + R, type cmd, and then press Ctrl + Shift + Enter.
- As an alternative, click the Start Menu, input cmd, then choose Run as Administrator by right-clicking Command Prompt.
You should now see a black command window open.
2. Identify Your USB Drive
Since CMD interacts directly with system storage, it's crucial to identify the correct USB drive to avoid formatting the wrong one.
Find the USB Drive
Step 1. Type the following command and press Enter:
diskpart
This launches the Disk Partitioning tool.
Step 2. Type:
list disk
This will show every storage drive that is attached to your computer. You will see something like this:
Step 3. Identify your USB drive by looking at its size. In this example, Disk 1 is the USB drive.
Important: Double-check the disk number before proceeding. Formatting the wrong disk will result in data loss.
3. Select the USB Drive and Clean It
Once you've identified the correct disk, select it using the following command:
select disk X
(Replace X with the correct disk number, e.g., select disk 1.)
To ensure no errors interfere with formatting, wipe the disk completely:
clean
This command removes all partitions, making the drive unallocated.
4. Create a New Partition
After cleaning the disk, create a primary partition:
create partition primary
5. Format the USB Drive
Now that the USB has a fresh partition, it's time to format it with the desired file system.
Choosing a File System
- NTFS – Best for Windows, supports large files.
- FAT32 – Works with Windows, Mac, and Linux, but has a 4GB file size limit.
- exFAT – Ideal for large USB drives, supports big files, and works on multiple operating systems.
To format the drive, use one of the following commands:
For FAT32 (older devices and cross-platform use):
format fs=fat32 quick
For NTFS (Windows users):
format fs=ntfs quick
For exFAT (modern cross-platform support):
format fs=exfat quick
The quick option speeds up formatting; omit it for a deeper format.
6. Assign a Drive Letter (Optional)
To make the USB accessible in File Explorer, assign it a drive letter:
assign letter=X
(Replace X with an available letter, e.g., assign letter=H.)
7. Exit DiskPart and Verify the USB Drive
Step 1. Type exit to close DiskPart.
Step 2. Type exit again to close CMD.
Step 3. Open File Explorer and check if the USB drive appears. It should now be formatted and ready for use.
Can't Format USB Flash Drive with CMD? Fix The Common Issues
1. USB Drive Not Detected in DiskPart
- Try a different USB port.
- Ensure the USB is properly connected.
- Restart the computer and try again.
2. "Disk is Write-Protected" Error
If you get a write protection error, remove it using:
attributes disk clear readonly
Then retry the formatting steps.
3. "The Format Did Not Complete Successfully" Error
- Run chkdsk X: /f (replace X with your drive letter) to fix errors.
- Ensure no files are open from the USB.
- Try using a different file system (exFAT instead of NTFS).
4. "Windows Cannot Format This Drive" Error
If you cannot format the USB, force format with:
format fs=ntfs /x
The /x switch forces the drive to dismount before formatting.
Understand Different File Systems for USB Flash Drive
When formatting a USB flash drive, selecting the right file system is crucial because it determines compatibility, performance, and storage efficiency. Windows allows you to format a drive in NTFS, FAT32, or exFAT, each having different strengths and weaknesses. Below is an in-depth look at these file systems.
1. NTFS
It is the default file system used by Windows operating systems. It provides advanced features like encryption, compression, and file permissions.
Pros:
✅ Supports very large files (up to 16TB)
✅ More secure with file encryption and permissions
✅ More efficient for modern Windows systems
✅ Less risk of file fragmentation
Cons:
❌ Not natively supported by macOS (read-only without extra software)
❌ Limited compatibility with gaming consoles and older devices
❌ More complex than FAT32 or exFAT, with added overhead
Best for:
- Windows users who do not need to use the drive on Mac/Linux
- External hard drives for Windows systems
- USB drives storing large individual files (4GB or larger)
- Bootable Windows installation media
For most users, exFAT is the best option unless you need specific compatibility.
2. FAT32
FAT32 is the oldest file system still in use. It offers maximum compatibility with different operating systems and devices but has limitations on file sizes and partition sizes.
Pros:
✅ Works on Windows, macOS, Linux, gaming consoles, and more
✅ Great for USB drives used across multiple devices
✅ Lower storage overhead and simple file management
Cons:
❌ 4GB file size limit (Cannot store large videos or files)
❌ 2TB partition size limit
❌ Less efficient than NTFS and exFAT
Best for:
- USB drives for sharing files between Windows, macOS, and Linux
- Older devices that don't support NTFS or exFAT
- Flash drives used for gaming consoles (PS3, Xbox 360, etc.)
- Car audio systems and smart TVs
3. exFAT
exFAT was designed by Microsoft to overcome FAT32's file size limitations while maintaining broad compatibility.
Pros:
✅ Supports large files (over 4GB)
✅ More efficient than FAT32 and NTFS for flash drives
✅ Works on Windows, macOS, and Linux
✅ Ideal for high-capacity USB drives and SD cards
Cons:
❌ Lacks advanced features like NTFS encryption and permissions
❌ Not compatible with some older gaming consoles or devices
Best for:
- USB flash drives and SD cards above 32GB
- File transfers between Windows and macOS without limitations
- Storing large videos, game files, and backups
How to Convert USB File Systems Without Losing Data
If you have already formatted your USB but need to switch file systems without losing data, you can convert it using CMD:
- Convert FAT32 to NTFS:
convert X: /fs:ntfs
(Replace X with the USB drive letter.)
- Convert NTFS to FAT32 or exFAT (without losing data is not possible) Unfortunately, Windows does not support direct conversion from NTFS to FAT32 or exFAT. You must back up your data and reformat the drive. Alternative Ways to Format a USB Drive
If you prefer not to use CMD, try these alternatives:
- File Explorer: Right-click the USB drive in This PC → Format → Choose file system → Click Start.
- Disk Management: Open Disk Management (Win + X → Disk Management) → Right-click USB → Format.
- Third-Party Software: Tools like Donemax Data Recovery, Rufus, EaseUS Partition Manager, or MiniTool Partition Wizard provide advanced formatting options.
Recover Lost Data from a USB Flash Drive After Erasing with CMD
Formatting erases everything from the USB flash drive. If you have lost data due to formatting your USB flash drive with CMD, you can use data recovery software - such as Donemax Data Recovery to get the lost data back.
Donemax Data Recovery
- Recover permanently deleted files from a USB flash drive.
- Unformat a USB flash drive and get all lost data back.
- Recover inaccessible or hidden data from a USB flash drive.
Step 1. Download and install Donemax Data Recovery on your computer, then insert the USB flash drive into your computer. Open Donemax Data Recovery, select the USB flash drive to start data recovery.
Step 2. Once you've selected the USB flash drive, click on Scan button. Then Donemax Data Recovery deeply scans the USB flash drive and find all lost files.
Step 4. After scan, it finds all lost files. Select the wanted files, click on Recover button to save them.
💡 Note: If you will sell, donate or dispose of your old USB flash drive, you can use disk wipe software - Donemax Data Eraser to wipe the USB flash drive - making everything stored on it be unrecoverable.
Conclusion
Formatting a USB flash drive using CMD (Command Prompt) is a powerful and efficient way to fix errors, remove malware, and optimize storage. By following this step-by-step guide, you can format your USB drive safely and choose the best file system based on your needs.
For general use, exFAT is recommended, while FAT32 is ideal for older devices, and NTFS works best for Windows users handling large files.
By mastering these CMD commands, you‘ll have greater control over your USB drives and be able to troubleshoot storage issues like a pro! If you have lost data due to formatting the USB flash drive, don't panic, Donemax Data Recovery can help you recover all formatted data.


Donemax Data Recovery
One of the best data recovery programs to recover deleted, formatted or lost data from PC, Mac, HDD, SSD, USB drive, SD card, camera, RAID, Sever or other storage devices.
Related Articles
- Dec 23, 20249 Tricks for Fixing the 'CHKDSK Cannot Open Volume for Direct Access' Error
- Oct 05, 2024How to Format an APFS Drive to ExFAT: A Comprehensive Guide
- Feb 17, 202510 Fixes for Fixing External Hard Drive Not Showing Up in File Explorer or This PC
- Nov 13, 2024Can't Format System Hard Drive Partition? Find A Solution
- Oct 23, 2024How to Initialize an External Hard Drive on Windows and Mac?
- Feb 20, 2025Convert RAW to NTFS with CMD (Command Prompt) – A Complete Guide

Steven
Steven has been a senior writer & editor of Donemax software since 2020. He's a super nerd and can't imagine the life without a computer. Over 6 years of experience of writing technical solutions and software tesing, he is passionate about providing solutions and tips for Windows and Mac users.

Gerhard Chou
In order to effectively solve the problems for our customers, every article and troubleshooting solution published on our website has been strictly tested and practiced. Our editors love researching and using computers and testing software, and are willing to help computer users with their problems