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 command will completely erase everything on the drive you select. The process has proven to be irreversible so you should always proceed with care.
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).
- 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:
- 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
- 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
- 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:
- 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.