When it comes to managing disks and partitions on Windows, DiskPart in Windows is a powerful tool that often flies under the radar. Unlike the graphical Disk Management tool, DiskPart works through the command line, giving you precise control over your storage devices. Whether you want to create, delete, or format partitions, DiskPart can handle it all.
In this blog, we’ll break everything down in simple terms, with clear examples and explanations.
What is DiskPart in Windows?
DiskPart in Windows is a command-line utility that allows you to manage disks, partitions, and volumes. Introduced in Windows 2000, DiskPart replaced the older FDisk tool. It’s especially useful when you need advanced disk management features that are not available in the Windows GUI.
Unlike the graphical Disk Management tool, DiskPart can perform tasks without restarting your PC and offers more flexibility for automation through scripts.
How to Open DiskPart in Windows
Opening DiskPart is straightforward:
- Press Win + R to open the Run dialog.
- Type
cmd
and press Enter to open Command Prompt. - Type
diskpart
and hit Enter.
You’ll see a new prompt that says DISKPART>
, which means you’re ready to manage disks and partitions.
How DiskPart Works: Focus and Objects
The core principle of DiskPart is focus. Before you do anything, you must choose (or “select”) an object for DiskPart to work on — a disk, partition, or volume. Only one object is in focus at a time, which minimizes mistakes.
Basic DiskPart Commands
Here’s a breakdown of the most commonly used DiskPart commands:
1. Listing Disks, Volumes, and Partitions
Start by seeing what’s connected to your PC:
diskpart
list disk # Shows all physical disks
list volume # Lists all volumes on all disks
list partition # Lists all partitions on the selected disk
The list disk
command displays all available disks connected to your computer, including their number, status, size, and free space.
Disk ### Status Size Free Dyn Gpt
Disk 0 Online 500 GB 0 B
Disk 1 Online 1000 GB 500 GB
The list volume
command shows all volumes (like C:, D:, etc.). To use the list partition
command, you must first select a disk with select disk X
(replacing X with the disk number).
2. Selecting Disks, Volumes, or Partitions
To work with a specific item, select it:
select disk 0 # Focus on disk 0
select volume 1 # Focus on volume 1
select partition 2 # Focus on partition 2
Every command you run after this will act on the selected object.
Tip: Always double-check the disk number to avoid accidental data loss.
3. Clean a Disk
clean # first select disk, partition or volume then use clean command
The clean
command removes all partitions and data from the selected disk, making it completely empty. Use with caution!
Managing Partitions with DiskPart in Windows
DiskPart allows you to create, format, and delete partitions easily.
1. Create a Partition
Suppose you want to break a disk into a new partition:
create partition primary size=102400 # 100GB partition
- primary: Specifies a primary partition.
- size: Defines the size in MB.
This command creates a 00GB (102,400MB) primary partition on the selected disk. You can omit size
to use all available space.
2. Format a Partition
Turn your raw partition into a usable volume:
format fs=ntfs label=MyDrive quick
- fs: File system (NTFS, FAT32, exFAT).
- label: Name of the partition.
- quick: Performs a faster format.
3. Assign a Drive Letter
assign letter=E
This command assigns a drive letter to the partition, making it accessible in Windows Explorer.
4. Delete a Partition
delete partition #Partition or Volume
Deletes the selected partition. Be cautious, as this will erase all data on the partition.
Advanced DiskPart Features
DiskPart isn’t just for basic tasks; it also offers advanced options:
- Convert a Disk to GPT or MBR : Convert a disk’s partition style
convert gpt # To GPT (good for >2TB and UEFI)
convert mbr # To MBR (classic BIOS systems)
You need to ‘clean’ the disk first before you can convert.
- Extending a Partition : Add unallocated space to an existing partition
extend size=20480 # Adds 20GB to the volume
Only works if unallocated space is next to (to the right of) the partition.
- Shrinking a Partition : Reduce the size of a volume (only NTFS-formatted)
shrink desired=40960 # Shrinks by 40GB
Handy for making space for new partitions.
- Mark a Partition as Active
active
This is crucial for bootable partitions.
Safety Tips When Using DiskPart
DiskPart is extremely powerful, but with great power comes great responsibility. Here are some safety tips:
- Backup your data before making changes.
- Always use
list disk
andlist volume
to confirm your targets. - Avoid using
clean
unless you are certain. - Double-check commands before pressing Enter.
Why Use DiskPart Instead of Disk Management?
DiskPart in Windows is preferred when you need:
- Advanced partitioning that GUI tools can’t handle.
- Scriptable disk operations for automation.
- Managing disks that Windows Disk Management fails to detect or modify.
Conclusion
DiskPart in Windows is a versatile tool for anyone looking to take control of their storage devices. From basic partitioning to advanced disk management, it gives you the flexibility and precision that the GUI tools cannot. By understanding its commands and using them carefully, you can safely and effectively manage your disks like a pro.
Whether you are a beginner or an IT professional, mastering DiskPart can save you time and help avoid common disk management issues.