Diskpart Commands: How to Manage Hard Drive Partitions in Windows 11/10

Reading time icon 13 min. read


Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team Read more

Efficient hard drive management is essential for maintaining an organized and optimized computer system. Windows operating systems offer various tools to help users manage their data, and Diskpart is one such powerful utility. Diskpart allows users to manipulate hard drive partitions directly from the command line, providing granular control over disk space allocation.

Whether you want to create, extend, delete, or format partitions, Diskpart offers a command-line-driven approach that’s particularly useful for system administrators and advanced users. This guide delves into the details of using Diskpart to manage hard drive partitions effectively in Windows 11/10.

What is Diskpart?

Diskpart, short for “Disk Partition,” is a command-line utility included in Windows 11/10 that empowers users to manage disks, partitions, and volumes. Unlike graphical interfaces, Diskpart operates solely through text-based commands, offering a powerful way to interact with storage devices. It’s especially valuable for managing partitions in scenarios where the graphical interface might not be accessible, such as during system recovery or maintenance.

Diskpart provides a comprehensive set of commands that enable users to create new partitions, extend existing ones, format partitions with different file systems, and even remove partitions entirely. Its versatility and direct control over disk structures make it a preferred tool for those who require a more hands-on approach to disk management.

Precautions to take while using Diskpart commands

While Diskpart can be a highly effective tool, it’s essential to take precautions before using its commands to avoid unintended data loss or system disruptions.ย 

Here are some precautions to consider:

  • Backup Your Data: Before performing any disk management operations using Diskpart, create backups of your critical data. Diskpart commands can lead to irreversible changes, and having a backup ensures that you can restore your data if something goes wrong.
  • Double-Check Disk Selection: Make sure you’re selecting the correct disk and partition when applying Diskpart commands. A wrong selection can result in unintended changes to your system.
  • Understand Commands: Familiarize yourself with the specific commands you’re going to use and their implications. Misinterpreting commands can lead to data loss or system instability.
  • Use “List” Commands: Utilize commands like list disk, list partition, and list volume to get a clear view of your disk configuration before making any changes. This helps you verify your selections.
  • Avoid Direct “Clean” Command: Be cautious with the clean command, as it removes all partitions from a selected disk without confirmation. This command can lead to complete data loss if not used carefully.

List of common Diskpart commands

Diskpart commands are the building blocks of disk management. Here’s a list of common commands along with their purposes:

Command Use
list disk Displays a list of available disks.
select disk <number> Selects a specific disk for further actions.
detail disk Provides detailed information about the selected disk.
attributes disk clear Clears read-only or hidden attributes on a disk.
online disk Brings a disk online if it’s marked as offline.
offline disk Takes a disk offline to prevent it from being accessed.
clean Removes all partitions and volumes from a disk.
convert gpt Converts the selected disk to the GPT partition style.
convert mbr Converts the selected disk to the MBR partition style.
create partition primary size=<size> Creates a primary partition with a specified size.
create partition extended Creates an extended partition.
format fs=<filesystem> quick Formats a partition with the specified file system.
assign letter=<letter> Assigns a drive letter to a partition or volume.
remove letter=<letter> Removes a previously assigned drive letter.
active Marks the selected partition as active (bootable).
delete partition override Deletes the selected partition.
extend Extends a partition into adjacent unallocated space.
shrink desired=<size> Shrinks a partition by the specified size (MB).
create volume simple size=<size> Creates a simple volume with the specified size.
create volume stripe disk=<disk>... Creates a striped volume across specified disks.
create volume mirror disk=<disk>... Creates a mirrored volume across specified disks.
create volume raid5 disk=<disk>... Creates a RAID-5 volume across specified disks.
format quick Formats the selected volume quickly.
format fs=<filesystem> Formats the selected volume with the specified file system.
delete volume Deletes the selected volume.
list partition Shows all partitions on a selected disk.
list volume Lists all volumes on the system.
list volume verbose Provides detailed information about all volumes.
list partition verbose Provides detailed information about all partitions.
offline volume Takes the selected volume offline.
online volume Brings the selected volume online.

How to launch Diskpart on Windows 11/10

Launching Diskpart is a straightforward process. Here’s how you can do it:

  1. Press Windows + R to launch the Run Command box.ย 
  2. Type “cmd” and press Shift+Enter to open the Command Prompt with admin rights.Launch Command Prompt with Admin Rights
  3. In the Command Prompt, type diskpart and press Enter. This initiates the Diskpart utility.Diskpart Launched
  4. If prompted by User Account Control, click “Yes” to grant administrative privileges to Diskpart. You’ll now be within the Diskpart environment, ready to execute disk management commands.
  5. To view the complete list of available commands for DiskPart, simply type help in the command window and hit the enter key.Diskpart Commands
  6. After utilizing the Diskart, you can simply use the Exit command to come out of it.Exit Diskpart

How to check existing hard drives, volumes, & partitions using DiskPart

Before making any changes, it’s crucial to understand your disk’s current configuration. Diskpart can help you get this information:

  1. Open the Command Prompt and enter diskpart.
  2. Enter list disk to see a list of available disks on your system. Note or remember the disk number you want to work with.List Disk Command
  3. Type select disk <number> to choose the disk you want to inspect.
  4. Similarly, use the list partition and list volume commands to see the partitions and volumes on the selected disk.

How to create a partition using Diskpart

Creating a partition using Diskpart provides you with control over its size, file system, and drive letter assignment.ย 

Creating a partition using Diskpart involves a few steps. Let’s go through the process:

  1. Launch Diskpart as described earlier.
  2. To access the disk list, use the list disk command, and then choose the desired disk by entering its corresponding number with the select disk # command, where โ€œ#โ€ is the disk number.
  3. Before beginning to create a partition, you need to clean the disk so there are no partitions already. So, be very careful while selecting the disk for parting it. To ensure that you have selected the right disk for partitioning, again use the list disk command and look for the asterisk mark against your selected disk. The asterisk mark indicates that further commands will be taken under the selected disk.Ensure You Selected The Right Disk
  4. After selecting the disk, use the clean all command to wipe out the disk. (optional step)
  5. Once the disk is wiped out, use the create partition primary command to create a partition using the entire space on that drive.
  6. If you want to create multiple partitions, you can assign how much space a partition could take. For that, use the create partition primary size=X command, where โ€œXโ€ is the size that you wish to set to the partition in megabytes.
  7. After creating the partition, format it with a file system using the format fs=<filesystem> quick command. For instance, use the format fs=ntfs quick for NTFS or format fs=fat32 quick for FAT32.
  8. Once the formatting process is complete, Diskpart will automatically assign a letter to the partition. In the event that it does not, you can manually set it by using the command assign letter=<letter>. Replace “<letter>” with the desired drive letter.ย 
Create Partition Using Diskpart
You can also create an additional partition in an already partitioned disk. Just skip step 4, i.e., using the Clean command to sweep the disk. Use the create partition primary size=X command to create a partition of X MB. Ensure that enough space is available to create a partition on an already divided hard disk.

How to extend a partition using Diskpart

Extending a partition allows you to combine unallocated space with an existing partition. Itโ€™s an excellent way to make efficient use of available space.

Here’s how you can do it:

  1. Launch Diskpart using the earlier method.
  2. Make sure that there is enough free space adjacent to the partition you plan to extend on the same drive without any partitions in between. Verify the contiguous availability of the free space.
  3. Use the list disk command to list all the attached disks on your system. Choose the disk containing the partition you want to extend using the select disk <number>.
  4. Next, use the list volume command to get the list of all the volumes under the selected disk.
  5. Now, choose the volume that you want to extend using the select volume # command. Insert the volume number in place of โ€œ#โ€.
  6. Next, use the extend command to add the entire free space to the selected volume. However, if you donโ€™t want to include the entire unallocated space to the selected volume, use the extend size=#, and replace โ€œ#โ€ with the amount of space you want to extend in megabytes.
Extend The Disk Using Diskpart

How to shrink a volume using Diskpart

Shrinking a volume allows you to reclaim unused space, which can then be used to create new partitions or extend existing ones. Here’s how you can shrink a volume using Diskpart:

  1. Launch Diskpart using the previously outlined steps.
  2. Type list volume to see a list of all volumes on your system. Note the volume number of the one you want to shrink.
  3. Enter select volume <number> to choose the volume you wish to shrink.
  4. To initiate the shrinking process, type shrink desired=<size> and press Enter. Replace โ€œ<size>โ€ with the amount of space you want to shrink the volume by in megabytes.
  5. Diskpart will calculate the available space that can be shrunk based on the specified size.
  6. Once the process is complete, you can exit Diskpart by typing exit and pressing Enter.
Shrink Volume Using The Diskpart

How to delete a partition using Diskpart

You can easily delete a partition, too, using Diskpart. Removing a partition should be done with caution, as it leads to data loss. Follow these steps:

  1. Open the Command Prompt and launch Diskpart.
  2. Select the disk containing the partition you want to delete using select disk <number>. If you donโ€™t know the disk number, use the list disk command.
  3. Now, use the select partition <number> command to select the partition that you want to delete. Use the list partition command if you donโ€™t know the partition number.
  4. After selecting the partition, use the delete partition command to delete it.
Delete A Partition Using Diskpart

Similarly, you can use the delete volume command to delete a partition.

How to completely wipe out the hard disk using DiskPart

If you encounter issues when formatting your system’s hard disk, an external hard drive, or a USB pen drive, you can use DiskPart to wipe them clean. However, please note that you cannot clean the disk on which your operating system is installed.

If you need to wipe out an entire hard disk using Diskpart, follow these steps with caution:

  1. Open the Command Prompt and enter diskpart.
  2. Type list disk and note the disk number you want to wipe.
  3. Select the disk by typing select disk <number>.
  4. Now type the clean all command and press Enter. This command will erase all data on the selected disk. Be patient; depending on the size of your hard disk, it could take even hours to complete this command.
Clean Disk Using Diskpart

Alternatives to Diskpart

While Diskpart is a powerful tool for managing hard drive partitions in Windows 11/10, there are alternative methods and third-party tools available for users who prefer different approaches. Here are a couple of alternatives to consider,

Windows Disk Management

Windows Disk Management

Windows provides a built-in graphical tool called “Disk Management.” To access it, right-click on the “Start” button and select “Disk Management.” This tool offers an intuitive interface where you can perform tasks like creating hard drive partitions, formatting, deleting, and resizing them. While it might not offer the same level of command-driven control as Diskpart, it’s user-friendly and suitable for most basic partition management needs.

Third-Party Partitioning Tools

Several third-party partitioning tools are available that provide advanced features and user-friendly interfaces. Tools like EaseUS Partition Master, MiniTool Partition Wizard, and AOMEI Partition Assistant offer capabilities beyond what Diskpart provides, including visual representations of your disk layout, more flexible partition resizing, and better data protection during operations. These tools can be especially useful for users who prefer not to work with command-line utilities.

FAQ

Can Diskpart commands be undone?

Unfortunately, Diskpart commands are irreversible and can lead to data loss if executed incorrectly. It’s crucial to double-check your commands and backup your data before making any changes using Diskpart.

Can I use Diskpart on external drives and USB devices?

Yes, Diskpart can be used on internal and external drives, including USB devices. However, exercise caution and make sure you select the correct disk to avoid accidental data loss.

Is it possible to resize volumes using Diskpart?

Yes, resizing the volume is possible using the Diskpart shrink and extend commands.

Manage your system hard drive easily

Effective hard drive management is essential for maintaining a well-organized and optimized computer system. Diskpart provides a versatile and powerful solution for managing hard drive partitions in Windows 11/10. By understanding its commands and following the steps outlined in this guide, you can confidently create, extend, delete, and manage partitions according to your needs. Remember to exercise caution, back up your data, and double-check your actions before executing Diskpart commands. With this knowledge, you’ll be well-equipped to make the most of your disk space while ensuring the safety of your data.

Looking for more? Check out these OnMSFT.com posts on Diskpart.