In Windows, managing hard drives and their partitions can sometimes be challenging, especially due to the limited and somewhat confusing functionality of the official Windows Disk Management tool. When your internal or external hard drive gets corrupted and the system enters recovery mode, there is no graphical disk management tool available to help you fix hard drive problems. That's where DiskPart comes in.
DiskPart is a hidden Windows feature that requires a command line tool to run. It is built into Windows and is mainly used to manage hard drive partitions and fix hard drive errors. It is pretty straightforward to use and you only need to know a few commands to use it to create, shrink, extend or delete partitions.
How to use DiskPart on Windows 11 (or 10)
Start DiskPart on Windows
DiskPart can be accessed through command-line tools such as the Command Prompt or Windows PowerShell. You should have administrative privileges to open and use DiskPart on your system. If you haven't accessed it yet, here's how to do it.
- Right-click on start and select Terminal (Administrator) from the Power User Menu. In Windows 10 you can choose Command Prompt (Admin) or Windows PowerShell (administrator).
- At the command line, enter Disk part and press Enter to open it.
- Click Yes if you receive the UAC warning.
- You are now in the DiskPart environment and can start executing the commands.
- If you want to see all the commands supported by DiskPart at any time, type help and press Enter.
- When you are finished with the DiskPart environment, use the exit Order to get out of there.
Check current disks, volumes and partitions
Before making any changes to your hard drives via DiskPart, you can check the current layout including the number of volumes, partitions and other information. This will give you a clear overview of the drive architecture and avoid errors when executing the commands.
- In the DiskPart environment, type: List disks Command and press Enter. You will see all the hard drives (internal or external) connected to your system with details such as status, total size, free space, and more.
- Similarly, use the List volume Command to check the volumes on your system and List partition to take a look at the partitions.
Creating a partition with DiskPart
With DiskPart, you can quickly create partitions on your brand new drive or further split your existing drive for better data management. You have control over the partition size, drive letter and file system. Follow these steps.
- Under the DiskPart environment, you can view all the hard drives on your device by List disks Command.
- Now use the select disk N command to select the hard disk on which you want to create a partition. Replace N with the diskette number of your choice.
- If you want to create a new partition on the selected hard disk, you can do so using the clean everything command to make sure there are no partitions. This is an optional step, you can skip it if you don't want to completely erase and reformat the drive.
If you decide to clean the disk, do so carefully because DiskPart never sends a warning before executing a command. If you select the wrong disk, it will be completely erased and you will lose everything on it. To make sure you have selected the right disk, use the List disks command and look for the asterisk (*) next to the desired hard drive. The * indicates that this is the disk selected for further action.
- Next, use the create primary partition command to create a partition using all the unallocated space on the hard disk. If you want to allocate a specific amount of space to the partition, use the create primary partition size=X Command, where X is the desired partition size in megabytes (MB). Example: Create partition, primary size=2048.
- After you have created the partition, the next step is to format it with a file system. To do this, use Format fs=ntfsquick Command for the NTFS file format. Replace ntfs with fat32 or any other format according to your requirements.
- After formatting, DiskPart automatically assigns the letter to the new partition. However, you can also do this manually by Assign letter=G Command. Of course, replace G with the desired letter.
- start File Explorer and view the newly created partition.
That's the entire process of creating a new partition using DiskPart. You can create multiple parts of the disk by following these steps again. Just make sure there is enough unallocated space available.
Shrink a partition with DiskPart
If one or more of your partitions have extra space that can be used to extend another partition or create a new partition, you can shrink it using DiskPart. Here's how.
- In the DiskPart environment, use the List disks command to display all the hard drives on your system and then use the select disk N command to select the hard drive of your choice (replace N by the number of the desired diskette).
- Next, use the List volume Command to list all volumes under the selected disk.
- You can select the volume you want to reduce by Select volume X (replaced X with the volume number).
- Use the command Reduction desired=Y (replace Y with the amount of space in megabytes (MB) you want to remove from the disk); Example: Shrinkage desired = 2024.
- DiskPart shrinks the volume and creates unallocated space.
Extending a partition with DiskPart
If you're having trouble running out of disk space, you can use DiskPart to extend your existing partition if there's unallocated space right next to it. To do so, follow these steps.
- In the DiskPart environment, select the volume you want to extend by typing: Select volume X (replaced X with the disk number). Make sure you are on the desired disk.
- To extend the selected volume, use the command Expand size=Y (replace Y with the amount of space in megabytes you want to add to the disk); for example: Expand size=2024If you want to extend the volume to use all the available space, simply enter extend without specifying a size.
Deleting a partition with DiskPart
If you want to delete unnecessary partitions on your drive to merge them with another partition, you can easily do it via DiskPart by following the steps below.
- Select the hard drive whose partition you want to delete.
- Under the selected hard disk, use the List partition Command to list all partitions.
- Now use the Select partition N (Replace N with the partition number) Command to select the partition to delete.
- Finally, enter the Delete partition command and press Enter. If the partition is protected, such as a system or OEM partition, you may need to override Parameters, i.e. Override partition deletionAgain, make sure you really want to remove the partition before deleting its contents.
Completely erase a hard drive with DiskPart
If you want to completely wipe your hard drive including data and file system, you can also do that with DiskPart.
- In the DiskPart environment, use the List disks Command.
- Check the number of the hard drive you want to delete and use the select disk N Command to select the (replaces N with the desired disk number). Be very careful during this step.
- Finally, use the clean everything Command to completely erase the data on the selected hard drive. Depending on the hard drive size and type (SSD or HDD), this process may take several hours.
This command will completely erase the data and make it impossible to recover, so use it accordingly.
Why you should use DiskPart
DiskPart can seem intimidating as it requires a command line tool to work. However, no other disk management tool is as advanced and robust as this one. With just a few commands, you can have complete control over your disks and partitions. The best part is that it works equally well with internal and external drives. So if you want to partition an external SSD or HDD, DiskPart is your tool of choice.
A crucial aspect of DiskPart is that it helps you manage your hard drive even in recovery mode when Windows operating system fails to boot and graphical disk management tool is not available. It can help you fix hard drive related issues like unallocated space, corrupted partitions or incorrect partition formatting.
Master Disk Management with DiskPart
While using the Windows operating system, you may have to face some frustrations, but Disk Management should not be one of them. With DiskPart, everything you need is at your fingertips, from creating or deleting a partition to shrinking or extending it. Always remember that this program does not warn you before taking extreme measures like wiping the disk. You will not get a second chance to undo your actions and recover valuable data. Apart from that, it is an excellent tool for Windows users that brings more efficiency and accuracy in managing disk partitions.