diskpart is a Windows utility to create partitions on disk. It is similar to the Linux fdisk utility.
diskpart provides interactive command shell where we will enter related commands to partition, format disk and volumes. In order to run
diskpart we need Administrator privileges. Best way to get Administrator privilege is opening MS-DOS as Administrator by right clicking on it.
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
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
Now we will select 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
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
We will create a partition on selected disk. We will issue
create partition primary . There are primary and secondary partition type. IF we have less than 5 partition in a disk we can use primary for all of them.
> create partition primary
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
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 the 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
label option is used to set the name of partition which is shown to 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.
We can exit from the
diskpart interactive shell with
exit command like below.