Skip to content

DISKPART Windows command

The Diskpart command in Windows is a powerful tool that allows users to manage disk partitions effectively. With Diskpart, users can create, delete, format, and resize partitions on their hard drives. This command-line utility provides more control and flexibility compared to the standard Windows Disk Management tool. By using Diskpart, users can easily perform advanced disk management tasks without the need for third-party software. It is especially useful for system administrators and power users who need to work with disk partitions frequently. Diskpart operates through a command-line interface, allowing users to input commands to perform various disk management operations. Understanding the syntax and available commands of Diskpart is essential to use it effectively. Overall, the Diskpart command is a valuable tool for managing disk partitions efficiently in Windows systems.

Terminal window
DISKPART
OptionDescription
selectSelect a disk or volume
listList the disks or volumes
createCreate a partition or volume
deleteDelete a partition or volume
formatFormat a partition or volume
assignAssign a drive letter or mount point
detailDisplay detailed information
onlineBring an offline disk or volume online
offlineTake a disk or volume offline
extendExtend a volume
shrinkShrink a volume
convertConvert the format of a volume
exitExit DiskPart
ParameterDescription
DiskNumberThe number of the disk to be operated on
VolumeNumberThe number of the volume to be operated on
FilesystemThe file system to be used when formatting a partition
Terminal window
diskpart
list disk

Displays a list of all available disks on the system.

Terminal window
diskpart
select disk 1

Selects disk 1 as the focus for subsequent operations.

Terminal window
diskpart
attributes disk

Displays the current attributes of the selected disk.

Terminal window
diskpart
select disk 1
clean

Cleans the selected disk by removing all partitions and volumes.

Terminal window
diskpart
select disk 1
create partition primary size=1024

Creates a primary partition with a size of 1024 MB on the selected disk.

Terminal window
diskpart
select disk 1
select partition 1
assign letter=E

Assigns drive letter E to partition 1 on the selected disk.

Terminal window
diskpart
select volume 1
extend

Extends the selected volume to utilize all available unallocated space.

Terminal window
diskpart
select disk 1
select partition 1
remove letter=E

Removes drive letter E from partition 1 on the selected disk.

To use the diskpart command in CMD, execute the following command:

Terminal window
diskpart

How can I list all disks using diskpart in CMD?

Section titled “How can I list all disks using diskpart in CMD?”

To list all disks using diskpart in CMD, use the following command:

Terminal window
list disk

How do I select a disk to work with using diskpart in CMD?

Section titled “How do I select a disk to work with using diskpart in CMD?”

To select a disk using diskpart in CMD, follow these steps:

Terminal window
list disk
select disk <disk_number>

How do I create a new partition using diskpart in CMD?

Section titled “How do I create a new partition using diskpart in CMD?”

To create a new partition using diskpart in CMD, execute the following commands:

Terminal window
select disk <disk_number>
create partition primary size=<desired_size>

How can I format a partition using diskpart in CMD?

Section titled “How can I format a partition using diskpart in CMD?”

To format a partition using diskpart in CMD, use the following command:

Terminal window
format fs=ntfs quick

How do I assign a drive letter to a partition using diskpart in CMD?

Section titled “How do I assign a drive letter to a partition using diskpart in CMD?”

To assign a drive letter to a partition using diskpart in CMD, follow these steps:

Terminal window
list volume
select volume <volume_number>
assign letter=<desired_letter>

How can I extend a volume using diskpart in CMD?

Section titled “How can I extend a volume using diskpart in CMD?”

To extend a volume using diskpart in CMD, execute the following commands:

Terminal window
select volume <volume_number>
extend

How do I delete a partition using diskpart in CMD?

Section titled “How do I delete a partition using diskpart in CMD?”

To delete a partition using diskpart in CMD, follow these steps:

Terminal window
list volume
select volume <volume_number>
delete volume

How can I clean a disk using diskpart in CMD?

Section titled “How can I clean a disk using diskpart in CMD?”

To clean a disk using diskpart in CMD, use the following commands:

Terminal window
select disk <disk_number>
clean
  • Creating, deleting, and formatting partitions on a disk
  • Assigning or changing drive letters
  • Setting active partitions
  • Extending or shrinking volumes
  • Converting disks between basic and dynamic
  • Converting disks from MBR to GPT
  • Managing virtual hard disks
  • Viewing disk information
  • Setting disk attributes
  • Resizing partitions