Diskpart: The Command-Line Disk Partitioning Tool

Download now

Diskpart is a text-based command interpreter built into Windows for managing disks, partitions, and volumes — more powerful and more dangerous than the graphical Disk Management tool.

Updated August 9, 2026 · PC Utility Hub Editorial Team

Launching diskpart

Open an elevated Command Prompt or PowerShell window and type diskpart, then press Enter. This opens a separate DISKPART> prompt where all further commands are typed.

diskpart

Core commands

CommandPurpose
list diskShows all physical disks attached to the system
select disk NSelects a disk by its number for further commands
list partitionShows partitions on the selected disk
select partition NSelects a partition
list volumeShows all volumes with drive letters
cleanErases the partition table on the selected disk
create partition primaryCreates a new primary partition
format fs=ntfs quickQuick-formats the selected partition
assign letter=EAssigns a drive letter
activeMarks the selected partition as active/bootable

Why diskpart is riskier than Disk Management

Unlike Disk Management, diskpart won't ask 'are you sure' before a destructive command executes against the selected object — it trusts that you selected the right one.

Warning: diskpart operates on whatever disk or partition is currently 'selected' with no visual confirmation dialog. Running 'clean' or 'format' on the wrong selected disk destroys all data on it with no undo. Always run 'list disk' and confirm the disk number before selecting and modifying anything.

Common uses

  • Creating or deleting partitions when Disk Management's GUI options are grayed out.
  • Cleaning a USB drive completely before creating a bootable installer.
  • Extending or shrinking volumes from a script.
  • Marking a partition active for dual-boot or bootable media setups.
  • Converting a disk between MBR and GPT (using 'convert gpt' or 'convert mbr' — requires the disk to have no partitions).

diskpart vs Disk Management

Disk Management (diskmgmt.msc) is the graphical equivalent and is safer for routine tasks like resizing or formatting existing volumes, since it shows confirmation prompts and a visual disk map. diskpart is preferred for scripting, batch operations, and tasks the GUI doesn't expose, such as certain GPT/MBR conversions or working around a Disk Management bug.

Frequently asked questions

Is diskpart safe to use?
It's safe when you double-check the selected disk/partition before every destructive command. It has no confirmation prompts, so mistakes affect the wrong drive silently.
Can diskpart recover a deleted partition?
No, diskpart creates and deletes partitions but doesn't recover data. Use a file recovery tool if you deleted a partition by mistake and need the data back.
How do I exit diskpart?
Type exit at the DISKPART> prompt to return to the regular command line.