diskpart is a Windows utility to create partitions on the disk. It is similar to the Linux fdisk utility. diskpart provides an interactive command shell where we will enter related commands to partition, format disk, and volumes. In order to run diskpart we need Administrator privileges. The best way to get Administrator privilege is opening MS-DOS as Administrator by right-clicking on it.
diskpart Command Interactive Mode
diskpart is mainly used by its interactive shell. So we should enter this shell with the
diskpart command. All commands issued bellow are used in interactive
diskpart Command Help
There are a lot of command supported by
diskpart . We can list these commands with
List Disk and Partitions
First we need to know how many disk there are. We will use
list disk command for this. We will also get following information about disks.
> list disk
Select Disk To Format
Now we will select the second disk which is numbered as 1. Because disk numbers start from 0. We will use
select disk 1 . In order to execute format commands, we should select a disk.
> select disk 1
Clean Drive Partition Table and Information
If there is an already set configuration we should clear them to make things simple. We will use
Check Disk Selection
In order to execute commands to format disk we should select the disk and partition. We have already selected disk but we can check this selection with
list disk command too. Selected disk will have asterisk before its name.
> list disk
Create New Partition Table
We will create a partition on the selected disk. We will issue create partition primary. There are primary and secondary partition types. IF we have less than 5 partitions in a disk we can use primarily for all of them.
> create partition primary
List Existing Partition Table and Information
Now we can list partition we have already created. We will use
list partition command for this. Also following information about partition will be listed
- Partition name
- Partition Type
> list partition
Select Partition To Modify
In order to operate on the given partition, we should select the partition with the
select partition command. This will select selected disks given partition according to number.
> select partition 1
In order to use partition we will activate it. We will use
This is one of the most important part. We will format the selected and activated partition. We will use
format command. Also, we will specify the file system type with the FS option. label option is used to set the name of partition which is shown to the user. quick specifies the format operation speed. In this example, we set file system type
NTFS and label
> format FS=NTFS label=D quick
In order to use the partition, we should assign a letter to the formatted partition. We will use
assign command with
letter option. In this example, we assign letter
E to the partition.
> assign letter=E
We can see from screenshot that we have tried to assign
D previously which is already assigned. This produced error and operation is not completed.
Exit From Diskpart Interactive Shell
We can exit from the
diskpart interactive shell with
exit command like below.