Learn how to manage disks in Windows using the Diskpart command
Last Update: Feb 18, 2025 | Published: Feb 12, 2025
Diskpart is a powerful command-line utility in Windows that allows users to manage their hard drive, disks, partitions, and volumes with precision and control. This article covers key commands, syntax, and best practices to help you manage your storage devices effectively on any version of Windows.
Diskpart is accessed from the command line.
At this point, you’re at the DISKPART prompt in the local computer’s disk subsystem.
Understanding how Diskpart commands work is key. One word = “focus.” There are three steps to using Diskpart.
For instance, we can first type ‘list disk’ to list the state of all disks in my Windows 11 PC. This will display both an online disk and an offline disk.
We see our current disks. I have a single ‘virtual’ disk, ‘Disk 0’. It is Online (of course), and is 60 GB in size. It is not a Dynamic Disk (Dyn is null), and the partition type is ‘GPT’.
As you can see, focus is the linchpin to how Diskpart works. Thankfully, it is very precise – harder to make any mistakes, in my opinion.
So, first, let’s do:
There we go. We have 4 partitions. As I’m sure you’re familiar with the Windows Disk Management console, this will undoubtedly look familiar to you. Partition 3 shows 59 GB in size, that is our ‘C: drive.’
Let’s go ahead and show you how to handle the addition of a new disk to the computer. Behind the scenes, I will add a 100GB virtual hard disk using the Hyper-V Manager interface because this is a virtual machine (VM). Then, we’ll need to initialize it, select the new disk, and create a partition…let’s not get ahead of ourselves. One moment.
Now we have two disks. You can see that ‘Disk 1’ is the new 100GB disk.
We’ve selected Disk 1. When we list partitions, it shows there aren’t any.
We’ve created our new primary partition. When we ‘list partition‘, we see that Partition 1 is selected (due to the ‘*’ to the left of the partition.
Now all we need to do is create a new disk volume:
Done! The filesystem is NTFS, the drive label is ‘Extra’, and I ‘quick formatted’ the current volume.
We can see our C: drive, our current D: drive (a virtual DVD drive), and the selected Volume 4. There’s the ‘Extra’ label.
Let’s assign a drive letter next.
Voila! There’s a popup from Windows identifying a new volume recognized and accessible in the operating system. Let me open File Explorer and Disk Management to confirm all our hard work.
Everything looks good. Let’s backtrack a bit and go over some of the more rudimentary basics of the syntax in Diskpart.
After starting Diskpart by typing in ‘diskpart’ in your admin command prompt, the new interpreter opens. Here are the basic commands and syntax when using Diskpart:
Command | Description | Example |
---|---|---|
diskpart | Opens the Diskpart utility | diskpart |
list disk | Lists all disks | list disk |
list volume | Lists all volumes | list volume |
list partition | Lists all partitions on the selected disk | list partition |
select disk X | Selects disk number X | select disk 1 |
select volume X | Selects volume number X | select volume 2 |
select partition X | Selects partition number X | select partition 1 |
create partition primary size=XXXX | Creates a primary partition of specified size | create partition primary size=10000 |
format fs=ntfs quick | Formats the selected partition with the NTFS file system | format fs=ntfs quick |
assign letter=Y | Assigns the drive letter Y to the selected volume | assign letter=D |
clean | Removes all partitions and volumes from the selected disk | clean |
detail partition | Shows detailed information about the selected partition | detail partition |
Here are some general tips and tricks.
If you need to convert the partition style from MBR to GPT, you can type ‘convert gpt‘ on a selected partition.
Another common troubleshooting step is repairing MBR and GPT partitions. A very simple and succinct Diskpart command – ‘clean’. After you’ve selected a particular disk (using for example ‘select disk 1’), you can use the diskpart clean command to erase all partitions and volumes from the disk. It’s similar to wiping the master boot record.
Note – you can use diskpart on computers running BIOS or UEFI mode.
Diskpart was introduced in Windows 2000, replacing the rather old, long-in-the-tooth, fdisk command. A command interpreter helps you manage your computer’s drives (partitions, disks, volumes, or virtual hard disks) from the command line. The most basic equivalent to a GUI in Windows is the MMC-based Disk Management tool.
Diskpart offers excellent detail when displaying information like system volume, system partition, which volume is your boot volume, and even lists specific types of volumes:
Every version of Windows (including Windows client and Windows Server) since Windows 2000 has included Diskpart – even “Home” editions. The only real prerequisite is that you’ll need to have administrative privileges in your command prompt or Windows Terminal shell.
Be careful when using Diskpart. You can irrevocably delete or lose data easily on your computers or servers. You can’t recover a deleted partition. Double-check your commands and double-check what disk, volume, or partition is active before you execute – more on this in a bit. If you mess up, you may be unable to boot Windows.
Here are common troubleshooting ideas you should always keep in mind when using Diskpart:
list disk
, list volume
, and list partition
to confirm you’re selecting the correct disk, volume, or partition.clean
Command: If a disk is not functioning correctly, use the clean
command to remove all partitions and volumes from the disk.create partition primary
and format fs=ntfs quick
commands to create and format a new partition.help
command within Diskpart to get detailed information about specific commands.Regarding best practices, let me show you an example of creating a mirrored volume on my client computer using Diskpart.
We have Disks 2 and 3 each with 50 GB free. First:
Sweet! In Disk Management and File Explorer, we can see the new mirrored volume.
Thank you for reading my article on using Diskpart.