Overview
When a USB drive will not format normally, the command line offers more control and can fix drives that File Explorer refuses to touch. This guide shows how to format a USB flash drive using diskpart in Command Prompt and using PowerShell, and how to verify the drive afterward.
The command line can format USB drives that File Explorer cannot.
Warning: Formatting erases all data on the drive, and selecting the wrong disk could wipe the wrong device. Double-check the disk number/size before running any command.
Key Takeaways
- diskpart can clean and reformat drives that fail in File Explorer.
- Identify the correct disk by its size before selecting it.
- Choose the file system: NTFS, FAT32, or exFAT to suit your use.
- PowerShell offers the same capability with Clear-Disk and Format-Volume.
Method 1 — Format With diskpart (Command Prompt)
1. Insert the USB drive. Open Command Prompt as administrator.
2. Type diskpart and press Enter.
3. List drives: list disk — identify your USB by its size.
4. Select it: select disk X (replace X with the correct number).
5. Wipe it: clean
6. Create a partition: create partition primary
7. Format it: format fs=exfat quick (or fs=ntfs / fs=fat32).
8. Assign a letter: assign, then type exit.
Tip: Use FAT32 for maximum compatibility with small drives, exFAT for large files and cross-platform use, and NTFS for Windows-only drives over 32 GB.
Method 2 — Format With PowerShell
1. Open PowerShell as administrator.
2. List disks: Get-Disk — identify the USB by size.
3. Clean it: Clear-Disk -Number X -RemoveData (replace X with the disk number).
4. Create a partition and assign a letter: New-Partition -DiskNumber X -UseMaximumSize -AssignDriveLetter
5. Format it: Format-Volume -DriveLetter E -FileSystem exFAT -NewFileSystemLabel "USB" (use your new letter).
Check the USB Drive for Errors
1. Open Command Prompt as administrator.
2. Run a check/repair: chkdsk E: /f (replace E: with the drive letter).
3. Review the results for bad sectors or fixed errors.
Check the drive’s health after formatting.
Troubleshooting
Problem: diskpart says "access is denied".
Solution: Run Command Prompt as administrator. diskpart requires elevation.
Problem: FAT32 is not offered for a large drive.
Solution: Windows limits FAT32 formatting to 32 GB. Use exFAT or NTFS for larger drives.
Problem: The drive is write-protected.
Solution: In diskpart, run attributes disk clear readonly after selecting the disk, then retry. Check any physical lock switch on the drive.
Problem: You picked the wrong disk number.
Solution: Always confirm by size with list disk / Get-Disk before clean. Never run clean on your system disk.
Conclusion
diskpart and PowerShell give you full control to format and revive USB drives. Just identify the right disk by size first, choose a suitable file system, and verify the drive with chkdsk afterward.
</w:pBdr><w:spacing w:before="220" w:after="40"/></w:pPr><w:r><w:rPr><w:b/><w:bCs/><w:color w:val="0B5394"/><w:sz w:val="21"/><w:szCs w:val="21"/><w:rFonts w:ascii="Calibri" w:cs="Calibri" w:eastAsia="Calibri" w:hAnsi="Calibri"/></w:rPr><w:t xml:space="preserve">About TechHub
This guide is part of the TechHub Knowledge Base. For more step-by-step IT guides and support, visit techhub.com.lk.















