DiskPart in Windows 10 is a command-line utility enabling you to perform disk partition operations using different commands. In this post, you can use DiskPart commands with typical examples.
DiskPart, replacing its predecessor - fdisk, is a command-line utility that provides the ability to manage disks, partitions or volumes in your computer running all versions of the operating system since Windows 2000, also including the latest Windows 10. Users can input DiskPart commands directly to organize hard disk partitions or create a text file script to perform multiple commands. Most disk partition operations that you can perform in Disk Management tool are integrated into DiskPart.
You will need to launch Windows 10/11 DiskPart with Administrator permission. One way is to type "diskpart" in the Search box, and then when diskpart appears in the search results, right-click it and select "Run as administrator". The other way is to press "Windows logo + R" keys and type "diskpart" in the box, and then click "OK".
Before you can use DiskPart commands in Windows 10, you must first list, and then select an object to give it focus. When an object has been focused, any DiskPart commands that you type will act on that object.
At the DISKPART> prompt, type "list disk" to display all the disks in your computer. Each one will have a specific disk number, starting with 0. An asterisk (*) under GPT row means the disk is of GPT partition style. Unless there is only one disk, you will have to tell DiskPart which disk to manage by using "select disk n" command to give it focus. n represents the number of the disk.
At the DISKPART> prompt, type "list volume" to display all the volumes on all disks. Each one will have a specific volume number, starting with 0. To tell DiskPart which volume to manage, you need to type "select volume n" to give it focus. n can be the number of the volume or the drive letter of the volume if has.
To view what DiskPart can for you, just type help to see a list of commands.
Next, we will take some of the most common commands that Diskpart uses as examples for you to get a further understanding.
Because when selecting a volume, the focus remains on it until you select a different volume, “select volume” command may not be used in each operation. Besides, the examples are performed one after one and the effect of the previous operation will be viewed in the next operation. If you only need to perform one of the operations, you need to select the volume before using the corresponding command.
➤ Note: Each time you type a command, you need to press the "Enter" key to apply it.
1. Delete Volume
To delete a volume, please refer to the following command:
▪ list volume
▪ select volume 6 (here take F: drive for example).
▪ delete volume
And then, you will receive a message says: DiskPart successfully deleted the volume.
Note: You cannot delete the system volume, boot volume, or any volume that contains the active paging file or crash dump.
2. Create Partition
To create a partition, please refer to the following command:
▪ create partition primary size=102400
And then, you will receive a message says: DiskPart succeeded in creating the specified partition.
The above command means to create a 102400MB (100GB) primary partition. To create other types of partition, you just need to replace primary with one of the following:
➧Note: To create a partition, there must be unallocated space on the disk.
3. Format Partition
Type list volume command, you will find the new created partition is RAW, which means you must format partition before you can use it. To format a partition, please refer to the following command:
▪ format fs=ntfs quick
And then, you will receive a message says: DiskPart successfully formatted the volume.
The above command means to perform a quick format on the partition. It will be formatted with NTFS file system. To create other file system partition like FAT, FAT32, you just need to replace ntfs with fat or fat32. The label can be any name as you like.
➧Note: DiskPart cannot format 32GB+ partition to FAT32. To format a large hard drive to FAT32, you have to turn to a third-party partition manager.
4. Assign Drive Letter
A partition without a drive letter will be hidden under "File Explorer". To assign a drive letter to an existing partition, please refer to the following command:
▪ assign letter=F (F can be replaced with another letter that has not been used yet).
And then, you will receive a message says: DiskPart successfully assigned the drive letter or mount point.
5. Extend Partition
To extend a partition, please refer to the following command:
▪ extend size=20480
And then, you will receive a message says: DiskPart successfully extended the volume.
The above command means to add 20480MB (20GB) to the volume 6. If no size is given, all of the contiguous unallocated space on its right side will be added.
➧Note: To extend a partition, there must be contiguous unallocated space on its right side.
6. Shrink Partition
To shrink a partition, please refer to the following command:
▪ shrink desired= xxxxxx
And then, you will receive a message says: DiskPart successfully shrunk the volume by 39GB.
➧Note: You can reduce the size of a volume only if it is formatted using the NTFS file system.
7. Mark Partition as Active
To mark a partition as active, please refer to the following command:
▪ active
And then, you will receive a message says: DiskPart marked the current partition as active.
The most common diskpart commands used on the disk should be the MBR and GPT conversion. To delete all partitions or volumes on a disk and convert the disk between MBR and GPT, please refer to the following command:
▪ list disk
▪ select disk 1
▪ clean
▪ "convert gpt" or "convert mbr".
As DiskPart alternative, AOMEI Partition Assistant Standard is a free partition manager software and disk management tool, that provides more features than DiskPart. It not only supports Windows 10, but also supports Windows 11/8.1/8, Windows 7. You can also resize the BitLocker partition when it is running out of space. With a user-friendly interface, it is very easy to use.
You can download this freeware and have a try. To get more advanced features, such as converting dynamic disk into basic without losing data, recovering lost partition, you can upgrade AOMEI Partition Assistant Standard to Professional version.
To perform an operation on a partition, you just need to right-click on it. The operations supported by AOMEI Partition Assistant Standard are as below:
The operations of disk management and step-by-step wizards are as below:
DiskPart in Windows 10/11 can meet the basic requirements of most users. And the free AOMEI Partition Assistant is more advanced than it and provides more amazing features.
For example, it can extend/shrink both FAT32 and NTFS partition. For extending a partition, its “Merge partition” allows users to add non-adjacent unallocated space into the target partition. It can format large partition (2TB at most) to the FAT32 file system. For partition style conversion, it can convert data disk between MBR and GPT without deleting partitions.
Can I use Diskpart to format a disk or partition? Yes, Diskpart allows you to format disks and partitions. Use the command we've shown in the post and follow the desired options and parameters.
What is the difference between a disk and a volume in Diskpart? In Diskpart, a disk refers to a physical storage device, while a volume is a partition on a disk. A disk can contain multiple volumes.
What should I do if Diskpart gives an "Access Denied" error? If you encounter "Access Denied" errors in Diskpart, ensure that you are running the Command Prompt or PowerShell as an administrator. Administrative privileges are necessary for many Diskpart operations.
How can I recover data from a deleted partition using Diskpart? Unfortunately, Diskpart does not provide a straightforward method for partition recovery. Consider using specialized data recovery tools like AOMEI Partition Assistant for this purpose.
How do I check the status of a disk or partition in Diskpart? Use the `detail disk` or `detail partition` commands in Diskpart to view detailed information about a specific disk or partition, including its status and attributes.