We can use the diskpart command to do several operations in the partitions of our selected drive. Let’s start with learning how to create a partition.
Creating a Partition – using Diskpart:
Just like before, to create a partition simply type “create partition primary” followed by the “size” option and the size you want your new partition to have in megabytes. If you do not specify a size all the available space will be used. For this example, lets create a 1GB partition. Here is what that would look like:
Create Partition Primary size=1000
Optionally you can assign a disk letter using the following command:
Replace D with the drive letter of your choice.
Finally, we need to format our drive, we can do so simply by using the following command:
format fs=ntfs quick
Replace ntfs with the filesystem of your choice.
Extending Partitions – using Diskpart:
Apart from creating a partition we can use the diskpart command to extend an existing partition. To do so however make sure that contiguous free space is available on your drive.
If there is, we need to select a volume to extent.
Use the “List Volume” command to view all the volumes in the currently selected drive.
Now select the volume you want to extend by using the “Select Volume” command followed by the number of the appropriate volume.
Select Volume 0
Finally use the “Extend” command to extend the selected volume.
The diskpart command will automatically use all the available space on your disk.
Deleting Partitions – using Diskpart:
We can use the diskpart command to delete partitions within our selected disk.
To do so, we first need to select the partition we want to delete. Simply use the “list partition” command to view all the available partitions within your selected drive.
To select the appropriate partition, use the “select partition” command followed by the number of the partition you want to delete.
Select Partition 0
Finally, to delete the selected partition use the delete partition command.
Warning all the data within the specified partition will be completely wiped, so be careful!
And that is it! You now know how to create, extend and delta partitions using the diskpart command directly form the command prompt.