Windows Diskpart Command Tutorial – POFTUT

Windows Diskpart Command Tutorial


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 shell.

> diskpart
Interactive Mode
Interactive Mode

diskpart Command Help

There are a lot of command supported by diskpart . We can list these commands with help

> help
Help
Help

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.

  • Status
  • Size
  • Free
  • GPT
> list disk
List Disk and Partitions
List Disk and Partitions

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
Select Disk
Select Disk

Clean Drive Partition Table and Information

If there is an already set configuration we should clear them to make things simple.  We will use clean command.

> clean
Clean Drive
Clean Drive

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
Check Disk Selection
Check Disk Selection

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
Create Partition
Create Partition

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
  • Szie
  • Offset
> list partition
List Partition
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
Select Partition
Select Partition

Activate Partition

In order to use partition we will activate it. We will use active command.

> active
Activate Partition
Activate Partition

Format Partition

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 D

> format FS=NTFS label=D quick
Format Partition
Format Partition

Assign Letter

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
Assign Letter
Assign Letter

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.

LEARN MORE  How To Use Fsutil To Check and Repair File System In Windows?

Exit From Diskpart Interactive Shell

We can exit from the diskpart interactive shell with exit command like below.

> exit

Leave a Comment