How to Use DiskPart to Format a Drive in Windows (2025 Guide)
How to Use DiskPart to Format a Drive in Windows (2025 Guide)
Want to format your USB drive, hard disk, or SD card using Windows commands? This guide shows you how to use DiskPart — the powerful built-in Windows tool — to clean, partition, and format any drive safely.
💡 What Is DiskPart?
DiskPart is a command-line utility in Windows that lets you manage disks, partitions, and volumes. It’s faster and more powerful than the graphical Disk Management tool, making it perfect for fixing corrupted or unrecognized drives.
⚠️ Important Warning
Formatting a drive erases all data permanently. Double-check the drive letter or number before executing any command. Once a drive is cleaned, recovery may not be possible.
🧰 Steps to Format a Drive Using DiskPart
Step 1: Open Command Prompt as Administrator
- Press Win + X → click Command Prompt (Admin) or Windows Terminal (Admin).
- Type
diskpartand press Enter.
Step 2: List Available Disks
list disk
This command displays all connected storage drives. Identify your target drive by its size. Example:
Disk 0 Online 500 GB
Disk 1 Online 32 GB
Step 3: Select the Target Disk
select disk 1
Replace 1 with your actual disk number. You’ll see: “Disk 1 is now the selected disk.”
Step 4: Clean the Disk (Optional)
clean
This removes all partitions and data from the selected disk, preparing it for a fresh format.
Step 5: Create a New Partition
create partition primary
This creates a new primary partition to make the drive usable again.
Step 6: Format the Partition
format fs=exFAT quick
You can change exFAT to another file system like NTFS or FAT32. Use quick to speed up formatting. Without it, the process takes longer but checks for bad sectors.
Step 7: Assign a Drive Letter
assign letter=E
This makes your newly formatted drive appear in File Explorer under the letter E (you can choose any unused letter).
Step 8: Exit DiskPart
exit
Close the tool — your drive is now formatted and ready to use!
🧾 Example: Full DiskPart Command Summary
diskpart
list disk
select disk 1
clean
create partition primary
format fs=exFAT quick
assign letter=E
exit
🧿 File System Options
| File System | Best For |
|---|---|
| FAT32 | Older devices, small drives (max 32GB) |
| exFAT | Cross-platform (Windows + macOS) |
| NTFS | Windows-only, supports large files |
🧩 Troubleshooting Tips
- If DiskPart shows “Access is denied”, make sure you opened Command Prompt as Administrator.
- If you see “Write-protected”, clear it first using
attributes disk clear readonly. - For corrupted drives, try running
chkdsk X: /f /rafter formatting (replace X with your drive letter).