Have you ever plugged in your USB flash drive only to find that Windows shows 0 MB, 6 MB instead of 32 GB or 64 GB, or displays errors like "Please insert a disk into USB drive", "The disk is write protected", or "You need to format the disk before you can use it"?
These issues can make it seem like your USB drive is permanently damaged. Fortunately, in many cases, the problem is caused by a corrupted partition table or damaged file system rather than failed hardware.
One of the most effective ways to repair these issues is by using DiskPart, a built-in Windows command-line utility. DiskPart allows you to completely clean the USB drive, create a new partition, and format it so Windows can use it again.
In this guide, you'll learn exactly how to use DiskPart to recover a corrupted USB drive safely.
Related Read: Discover more tech tips in our guide on How to Recover Deleted Files in Windows 11.
Table of Contents
When Should You Use DiskPart?
DiskPart is useful if your USB drive has problems such as:
- USB shows 0 MB capacity
- USB shows 6 MB instead of its original size
- Windows asks you to format the drive every time you connect it
- The USB appears as RAW
- The partition has disappeared
- The drive is inaccessible
- File system corruption
- Unable to create or delete partitions
- Bootable USB is no longer usable
- The USB isn't detected correctly after creating a bootable drive
If the USB has physical hardware damage, this method is unlikely to fix it.
What Is DiskPart?
DiskPart is Microsoft's built-in disk management tool available in Windows 10 and Windows 11. Unlike Disk Management, DiskPart gives you complete control over storage devices using commands. It can:
- Delete damaged partitions
- Clean partition tables
- Create new partitions
- Format drives
- Assign drive letters
- Mark partitions as active
Because DiskPart works directly with the storage device, you should always double-check every command before pressing Enter.
Step-by-Step Guide to Fix a Corrupted USB Drive
Step 1: Connect the USB Drive
- Insert the USB drive into your computer.
- Wait a few seconds for Windows to detect it.
- Close File Explorer if it automatically opens.
Step 2: Open Command Prompt as Administrator
- Press Windows + S
- Search for cmd
- Right-click Command Prompt
- Select Run as administrator (You can also open Windows Terminal as Admin).
Step 3: Launch DiskPart
Type the following and press Enter:
diskpart
If Windows displays a User Account Control (UAC) prompt, click Yes. You should now see the DiskPart console.
Step 4: Display All Storage Devices
Run:
list disk
Example Output:
DISKPART> list disk
Disk 0 476 GB
Disk 1 32 GB
Identify your USB drive by checking its storage capacity.
Step 5: Select Your USB Drive
Replace the number below with your USB drive's disk number:
select disk 1
DiskPart should display: Disk 1 is now the selected disk. Always make sure you've selected the correct disk.
Step 6: Clean the USB Drive
Run:
clean
This command removes the existing partition table and all partition information from the USB drive. After a few seconds, you'll see: DiskPart succeeded in cleaning the disk.
If you receive an access denied or write-protected error, check whether the USB drive has a physical write-protect switch or try the command on another USB port.
Step 7: Create a New Primary Partition
Now create a fresh partition by entering:
create partition primary
DiskPart will respond: DiskPart succeeded in creating the specified partition.
Step 8: Select the New Partition
Type:
select partition 1
This ensures the newly created partition is selected for formatting.
Step 9: Format the USB Drive
For most users, the FAT32 file system is the best choice because it works with Windows, Linux, macOS, TVs, gaming consoles, and many embedded devices:
format fs=fat32 quick
If your USB drive is larger than 32 GB or you need to store files larger than 4 GB, use exFAT instead:
format fs=exfat quick
You can also use NTFS if the USB will only be used with Windows:
format fs=ntfs quick
Step 10: Assign a Drive Letter
Finally, assign a drive letter:
assign
DiskPart will automatically assign the next available drive letter. You should now see the USB drive in File Explorer.
Step 11: Exit DiskPart
Type:
exit
Then close Command Prompt. Your USB drive should now be ready to use.
Complete DiskPart Command Sequence
For quick reference, here are all the commands in order. (Remember to replace select disk 1 with your actual USB disk number.)
diskpart
list disk
select disk 1
clean
create partition primary
select partition 1
format fs=fat32 quick
assign
exit
Common Errors and Solutions
USB Still Shows 0 MB
- Disconnect the USB drive and reconnect it.
- Run the DiskPart commands again.
- If the problem persists, the flash memory may be physically damaged.
"The Media Is Write Protected"
- Try another USB port.
- Check if the USB drive has a physical lock switch.
- If the error remains after trying multiple computers, the controller may have failed.
"No Media in Device"
If DiskPart reports "No Media", Windows can detect the USB controller but not the flash memory itself. This usually indicates a hardware failure that software cannot repair.
USB Capacity Is Incorrect
If your 64 GB drive appears as only 6 MB or another incorrect size, the clean command followed by creating a new partition often restores the correct capacity. If it doesn't, the USB controller firmware may be corrupted.
Final Thoughts
DiskPart is one of the most powerful built-in tools for repairing USB drives in Windows. In many cases, it can recover drives that appear corrupted, show the wrong storage size, or fail to mount correctly.
However, remember that DiskPart cannot repair physical hardware damage. If your USB drive continues to report 0 MB, No Media, or isn't detected even after following every step, the flash memory or controller may have permanently failed.
Before replacing the drive, it's worth trying the DiskPart method because it only takes a few minutes and often restores USB drives that seem unusable.
By carefully following the commands in this guide, you can safely rebuild your USB drive's partition table, create a fresh partition, and return it to working condition without installing any third-party software.
