diskpart (Disk Partition Utility)

What is diskpart?

Diskpart is a command-line utility in Windows operating systems (OSs) that is used to manage disks, partitions and volumes. It can be used to create, resize or delete hard drive partitions and set active or bootable partitions. This command line utility can also convert between basic and dynamic disks, repair corrupted master boot records (MBRs) and check disk integrity.

What is diskpart used for?

Diskpart can create, delete and format partitions on a hard drive. It can also be leveraged to assign, change or remove drive letters as well as mark or label partitions on a disk. Users can set the active partition, configure basic or dynamic disks, extend existing volumes and perform other tasks related to disk management.

disk partitioning
Manage disks, partitions and volumes in Windows with the diskpart command-line utility.

What is the diskpart command used for?

Users can type diskpart commands directly to configure storage or script diskpart to perform multiple commands via a text file script. Unlike many command-line utilities, diskpart does not operate in a single-line mode; instead, diskpart commands are read from standard I/O.

What is a diskpart clean command?

The diskpart clean command erases all data from a selected storage device like a hard disk drive or solid-state drive. When users execute the command, it writes zeros to every sector on the drive, wiping out all data as if the drive were new.

Erasing all data from a drive before selling or disposing of it or when preparing a drive for a new OS installation can be useful:

  • To use the diskpart clean command, the user must open the Command Prompt with administrator privileges, type "diskpart" and press Enter.
  • Once in the diskpart prompt, the user can select the drive to clean by typing "select disk x" (or the number of drives to be cleaned) and press Enter.
  • Then the user types "clean" and presses Enter to execute the command. It is important to note that the clean command is a destructive process that will delete all the data on the selected drive. Once executed, the data cannot be recovered.
The diskpart Windows utility
The diskpart Windows utility offers 38 commands for disk-related editing jobs.

What is GPT in diskpart?

The GUID (Globally Unique Identifier) Partition Table (GPT) replaces the older MBR partitioning scheme. It is a standard used by most modern OSs to store information on how a hard drive is divided into separate partitions. GPT stores more data than MBR and supports larger hard drives and drives split into multiple partitions.

The GPT partition table uses a GUID to identify partitions, allowing larger disk sizes and more partitions than MBR. It also includes a protective MBR, which prevents accidental disk repartitioning and corruption. Additionally, GPT has a backup copy of the partition table, which can recover the partition information if the primary copy becomes corrupted.

The "convert gpt" command in diskpart can be used to convert a disk from MBR to GPT or the "convert mbr" command to convert a disk from GPT to MBR. It is important to note that this process is destructive and will erase all data on the disk, so it is vital to back up important data before proceeding.

What is diskpart active?

In the diskpart utility, the "active" command is used to set the partition on a disk as active. The active partition is the partition that the computer's BIOS or Unified Extensible Firmware Interface (UEFI) will use to boot the OS. This means that the active partition must contain the boot files and bootloader for the OS.

Users can create, delete and manage hard drive partitions using commands such as "list," "select" and "active." The active command makes the selected partition or volume active, meaning that it will be used as the bootable partition for the system.

It is important to note that the "active" command only applies to MBR partitioned disks. GPT uses a different mechanism called UEFI to boot the OS and does not have the concept of an active partition.

See how to use diskpart to create, delete, clean or extend disk partitions.

This was last updated in February 2023

Continue Reading About diskpart (Disk Partition Utility)

Dig Deeper on IT operations and infrastructure management

Cloud Computing
Enterprise Desktop
Virtual Desktop