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.

DISKPART Syntax:

Terminal window
DISKPART

Windows DISKPART Options:

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

DISKPART Parameters:

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

How to use DISKPART command:

List all available disks

Terminal window
diskpart
list disk

Displays a list of all available disks on the system.

Select a disk to work with

Terminal window
diskpart
select disk 1

Selects disk 1 as the focus for subsequent operations.

Check disk attributes

Terminal window
diskpart
attributes disk

Displays the current attributes of the selected disk.

Clean a disk

Terminal window
diskpart
select disk 1
clean

Cleans the selected disk by removing all partitions and volumes.

Create a partition

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.

Assign a drive letter to a partition

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

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

Extend a volume

Terminal window
diskpart
select volume 1
extend

Extends the selected volume to utilize all available unallocated space.

Remove a drive letter from a partition

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

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

How do I use diskpart in CMD?

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

Terminal window
diskpart

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?

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?

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?

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?

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?

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?

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?

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

Terminal window
select disk <disk_number>
clean

Applications of the DISKPART Command

  • 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