This tutorial will teach you how to create disk partitions in Windows using diskpart command. Apart from how to create disk partitions in Windows using diskpart, you can also delete partitions using the diskpart command in Windows. Diskpart is the default Windows systems command line disk partitioning utility.
To demonstrate on how to create disk partitions in Windows using diskpart command. I’m going to add a secondary drive to my Windows server, we’ll then Create a Partition using diskpart command, Set label for the partition and assign a drive letter to the partition.
Apart from creating Logical volumes and partitions with diskpart command. You can also repair corrupted external HDD and flash Drives.
Please note that diskpart can be used not only to create a partition but also to delete or format it. Any improper execution of the commands will result in serious data loss which is irreversible. In such scenarios the only way you can get back your data is to make use of a partition recovery software that can help you recover data from formatted partition using disk part. Suppose you want to wipe the PC willingly, you have to follow a slightly different set of commands to format using diskpart.
How to create disk partitions in Windows using diskpart command
Without further ado, let’s dive in. Follow steps below to create disk partitions in Windows using diskpart command.
- Launching diskpart utility
To run diskpart, press Windows key + X keyboard shortcut. This will open the Power User menu, then select Command Prompt (Admin).
2. Now type diskpart on the command prompt. If you’re running Windows server, you can just run Powershell then launch diskpart on the cli.
3. List available disk drives using the command below:
4. Now select the drive you want to partition using select disk command. On my setup the disk is number 2 with 2GB of space unpartitioned.
select disk 1 list partition
5. Create a partition. This can be primary or logical depending on your setup. Here I’m creating a primary partition at the beginning of the free space and spans entire disk.
create partition primary
To specify size, e.g 1 GB, use
create partition primary size=1024
To create a logical partition for example:
create partition extended create partition logical list partition
6. The next step is to create a filesystem on the partition by formatting it. You can assign custom letter as well.
select partition 1 active format fs=ntfs quick label="Backup Partition" assign letter=G:
7. Again list disk, partition and volumes created.
list disk list partition list volume
How to delete disk partitions in Windows using diskpart command
Deleting a disk partition using diskpart is similar to creating, the difference is only that delete is used instead of create. For example to delete logical partition we created, do:
list disk select disk 1 list partition select partition 2 delete partition list partition
To clean entire disk, select it and issue the command clean
select disk 1 clean
Use the exit command to exit from the diskpart command line interface. To this end, you must have understood how to create disk partitions in Windows using diskpart command. More tutorials on Windows server Administration will come soon. Stay tuned.