Diskpart is a built-in Windows command-line tool for managing disks, partitions, and volumes. You use it by opening Command Prompt as administrator and typing commands like list disk, select disk, and create partition to perform tasks such as formatting drives, creating partitions, or wiping a disk. This guide explains the essential commands, how to run them safely, and what to do when things go wrong.
What Is Diskpart and Why Use It?
Diskpart has been part of Windows since Windows 2000, replacing the older fdisk tool. It is a text-based utility that gives you precise control over storage devices—internal hard drives, SSDs, USB flash drives, and memory cards. Unlike the graphical Disk Management tool, Diskpart can run from scripts, work in recovery environments, and handle tasks that the GUI cannot, such as cleaning a disk completely or converting a disk between MBR and GPT partition styles.
You might need Diskpart when:
- You want to delete all partitions on a drive and start fresh.
- You need to create a bootable USB drive by making it active.
- Disk Management shows errors or fails to perform an operation.
- You are repairing Windows from the command line in Recovery Mode.
How to Open Diskpart
Diskpart requires administrator privileges. To open it:
- Press Windows + X and select Terminal (Admin) or Command Prompt (Admin).
- If prompted by User Account Control, click Yes.
- Type
diskpartand press Enter.
You will see a DISKPART> prompt. Every command you type here applies to the currently selected disk, partition, or volume. The tool does not have a graphical interface; you must type commands in order.
Essential Diskpart Commands
Here are the commands you will use most often, in the order you would use them:
list disk– Shows all physical disks attached to the PC, with numbers (0, 1, 2…).select disk X– Chooses the disk you want to work on. Replace X with the disk number.list partition– Shows partitions on the selected disk.select partition Y– Chooses a specific partition.list volume– Shows all volumes (partitions with drive letters).select volume Z– Chooses a volume.clean– Removes all partitions and file systems from the selected disk, making it unallocated.create partition primary size=N– Creates a new primary partition of N megabytes.format fs=ntfs quick– Formats the selected partition quickly with the NTFS file system.assign letter=E– Assigns a drive letter to the selected volume.active– Marks the selected partition as active (for booting).exit– Closes Diskpart.
Step-by-Step: Format a USB Drive with Diskpart
A common task is wiping a USB drive that Windows refuses to format or that has become corrupted. Here is the exact sequence:
- Plug in the USB drive.
- Open Command Prompt as administrator and type
diskpart. - Type
list diskand note the number of your USB drive (usually the last one, but check its size). - Type
select disk 1(replace 1 with your drive number). - Type
clean– this removes every partition on the drive. - Type
create partition primary– creates a single partition using the whole drive. - Type
select partition 1. - Type
active– marks it as active (only needed if you want to boot from it). - Type
format fs=ntfs quick(orfs=fat32for compatibility with older devices). - Type
assign– automatically assigns a drive letter. - Type
exit.
If you want to make a bootable Windows installation USB, you would normally use the Media Creation Tool, but Diskpart can prepare the drive first by cleaning it and formatting it as FAT32.
How to Choose the Right Disk and Avoid Data Loss
The most dangerous part of Diskpart is selecting the wrong disk. The clean command deletes everything on the selected disk without any confirmation. To avoid disaster:
- Always run
list diskfirst and check the size column. A 32 GB USB drive will show as 29 GB or similar, not as 931 GB. - Double-check the disk number before pressing Enter.
- Unplug any external drives you do not need.
- Back up important data before using
cleanordelete partition.
If you accidentally select the wrong disk, stop immediately. Do not create partitions or format. Some data recovery software may be able to restore files, but there is no guarantee.
Common Problems and How to Fix Them
Diskpart sometimes fails or gives errors. Here are the most common issues:
- “Diskpart has encountered an error: Access is denied.” – You are not running as administrator. Close and reopen Command Prompt with admin rights.
- “The specified disk is not convertible.” – This happens when trying to convert a disk to GPT or MBR while it has partitions. Delete all partitions (or use
clean) before converting. - “There is no volume selected.” – You must select a volume before using volume commands like
formatorassign. - “The disk is write-protected.” – Some USB drives have a physical lock switch. Check the side of the drive. If there is no switch, the drive may be failing.
- “Diskpart cannot delete the active partition.” – You cannot delete the system or boot partition while Windows is running. Use a Windows installation USB and open Diskpart from the repair environment.
Diskpart vs. Disk Management vs. PowerShell
Windows offers several ways to manage disks. Diskpart is not the only option:
- Disk Management (diskmgmt.msc) – A graphical tool that is easier for beginners but slower for repetitive tasks and cannot clean a disk that has a protected partition.
- PowerShell – The modern replacement. Cmdlets like
Get-Disk,Clear-Disk, andNew-Partitiondo the same things as Diskpart but with more scripting power. Microsoft has not deprecated Diskpart, but new features are mostly added to PowerShell. - Diskpart – Still useful because it works in the Windows Recovery Environment and in WinPE, where PowerShell may not be available.
For a one-off format, Disk Management is fine. For scripting or repairing a stubborn drive, Diskpart is often the better choice.
Safety and Precautions
Diskpart is powerful and can permanently erase data. Follow these safety rules:
- Never run
cleanon a disk you are not sure about. - Use
detail diskafter selecting a disk to see its model and size before proceeding. - Remember that
cleandoes not securely erase data; it only removes the partition table. Files can still be recovered with special software. If you need to securely wipe a drive, useclean all(which writes zeros to every sector) but be aware it can take hours on large drives. - Do not use Diskpart to delete the system partition (usually partition 1 on disk 0) unless you are reinstalling Windows.
Frequently Asked Questions
Can I use Diskpart to convert a disk from MBR to GPT without losing data?
No, the convert gpt command requires an empty disk. You must back up your data, delete all partitions (or use clean), then convert. After that, you can create new partitions and restore your files.
What does “clean” do in Diskpart?
clean removes all partition tables and file system information from the selected disk, leaving it as unallocated space. It does not erase the actual data bytes, so recovery is sometimes possible. clean all overwrites every sector with zeros, which takes much longer but makes recovery nearly impossible.
Why does Diskpart say “The specified disk is not convertible”?
This error occurs when you try to convert a disk to GPT or MBR while it still has partitions. You must delete all partitions first. If the disk is the system disk, you cannot do this while Windows is running; you need to boot from installation media.
How do I make a USB drive bootable with Diskpart?
After cleaning and creating a primary partition, use active to mark it active, then format with format fs=fat32 quick if your firmware supports FAT32, or NTFS for larger files. Then copy the boot files (like Windows installation files) to the drive.
Is Diskpart still available in Windows 11?
Yes, Diskpart is still included in Windows 11 and works the same way as in Windows 10. Microsoft recommends PowerShell for new scripts, but Diskpart remains fully functional and is often the only option in recovery environments.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Hard Drive Very Slow Suddenly? Fixes That Work
- Windows Insider: Check New Windows 10 Features
- Restore Pitted Chrome Sink Drain Surrounds
- Error Performing Query Error Facebook: Fixes
- WiFi Not Working on HTC 10? Solved
- How to Stop Discord Opening on Startup