DiskPart is a built-in Windows command-line utility that lets you manage hard drives, SSDs, USB drives, and other storage devices. It allows you to create, delete, format, extend, shrink, and manage disk partitions using text commands instead of the graphical Disk Management tool. Available in Windows 11, Windows 10, and earlier versions of Windows, DiskPart is commonly used to prepare new drives, troubleshoot storage issues, convert partition styles, and perform advanced disk management tasks that may not be possible through the Windows interface. In this guide, you’ll learn what DiskPart is, what it’s used for, how to open it, and the most useful DiskPart commands for managing disks and partitions safely.
What Is DiskPart Used For?
DiskPart is designed to manage disks, partitions, and storage volumes from the command line. It provides more control than the Disk Management utility and can perform advanced operations that may not be available through the graphical interface.
Some of the most common tasks you can perform with DiskPart include:
- Create, delete, and format partitions.
- Extend or shrink existing partitions.
- Clean a disk by removing all partition information.
- Convert a disk between MBR and GPT partition styles.
- Mark a partition as active for booting (MBR disks only).
- Assign, change, or remove drive letters.
- Create and manage volumes on basic and dynamic disks.
- View detailed information about disks, partitions, and volumes.
- Prepare a new hard drive, SSD, or USB drive for use.
Because DiskPart works directly with your storage devices, any changes take effect immediately. Always double-check that you’ve selected the correct disk or partition before running commands, especially when deleting or cleaning a drive.
How to Open DiskPart in Windows
You can open DiskPart from Command Prompt or the Windows Recovery Environment (WinRE). Administrative privileges are required because DiskPart makes changes to your storage devices.
Method 1: Open DiskPart from Command Prompt
- Press Windows + S and search for Command Prompt.
- Select Run as administrator.
- If prompted by User Account Control (UAC), click Yes.
- Type diskpart and press Enter.

- If the command runs successfully, you’ll see the DISKPART> prompt, it means DiskPart is ready to accept commands.
Method 2: Open DiskPart from Windows Recovery Environment (WinRE)
If Windows won’t start, boot into the Windows Recovery Environment (WinRE) and open Command Prompt. Then type the command diskpart and press Enter:
This method is useful for repairing boot problems, managing partitions, or preparing a drive before reinstalling Windows.
Common DiskPart Commands
The following commands are the ones you’ll use most often when managing disks and partitions with DiskPart.
| Command | Description |
|---|---|
list disk | Displays all physical disks connected to your computer. |
select disk X | Selects the disk you want to manage. Replace X with the disk number. |
list partition | Shows all partitions on the selected disk. |
select partition X | Selects a specific partition on the current disk. |
list volume | Displays all storage volumes and their drive letters. |
select volume X | Selects a volume for management. |
create partition primary | Creates a new primary partition using available unallocated space. |
delete partition | Deletes the selected partition. |
format fs=ntfs quick | Quickly formats the selected partition using the NTFS file system. |
assign letter=X | Assigns a drive letter to the selected partition or volume. |
remove letter=X | Removes the assigned drive letter from a volume. |
extend | Extends the selected partition into adjacent unallocated space. |
shrink desired=10240 | Shrinks the selected partition by the specified size (in MB). |
clean | Removes all partition and volume information from the selected disk. |
convert gpt | Converts the selected disk to the GPT partition style. |
convert mbr | Converts the selected disk to the MBR partition style. |
exit | Closes the DiskPart utility. |
Important: Always verify that you’ve selected the correct disk or partition before running commands such as clean, delete partition, or format, as these operations can permanently erase data.
How to Use DiskPart
Before making any changes, you need to identify the correct disk. The following example shows how to view all storage devices connected to your computer.
1. List Available Disks
- Open DiskPart using one of the methods described above.
- At the DISKPART> prompt, type the command
list diskand press Enter:
DiskPart displays all connected storage devices, including internal hard drives, SSDs, and USB drives. Each disk is assigned a number (such as Disk 0, Disk 1, or Disk 2), along with its size, available free space, and partition style.
Carefully identify the disk you want to manage before continuing. Selecting the wrong disk could result in accidental data loss.
2. Select a Disk
After identifying the correct disk, select it by replacing X with its disk number: select disk X
For example, to select Disk 0, run: select disk 0
If successful, DiskPart displays the message:
Disk 0 is now the selected disk.
All commands you run afterward will apply to the selected disk until you choose a different one.
3. Create a New Partition
If the selected disk contains unallocated space, you can create a new primary partition using the command: create partition primary
By default, DiskPart uses all available unallocated space. If you want to create a partition of a specific size, specify the size in megabytes (MB).
For example, to create a 50 GB partition: create partition primary size=51200

After the command completes successfully, DiskPart creates the new partition and automatically selects it.
Note: If there is no unallocated space on the selected disk, you’ll need to shrink an existing partition or use another disk before creating a new partition.
4. Format the Partition
After creating a partition, format it with a file system so Windows can store files on it. For most users, NTFS is the recommended file system for internal drives.
To perform a quick format, run: format fs=ntfs quick
If you want to give the partition a name (label), use: format fs=ntfs label="Data" quick
DiskPart formats the selected partition and displays the progress. Once the process is complete, the partition is ready to use.
5. Assign a Drive Letter
If Windows doesn’t automatically assign a drive letter, you can do it manually.
To assign the next available drive letter, run: assign
To assign a specific drive letter, replace X with the letter you want to use: assign letter=E

After the drive letter is assigned, the partition appears in File Explorer and can be used like any other drive.
6. Delete a Partition
If you no longer need a partition, you can delete it using DiskPart. Deleting a partition removes all data stored on it, so back up any important files before proceeding.
First, display the partitions on the selected disk: list partition
Select the partition you want to delete by replacing X with the partition number: select partition X
For example: select partition 2
Then delete the selected partition: delete partition

If the operation is successful, DiskPart removes the partition and the space becomes unallocated, allowing you to create a new partition or extend an existing one.
Warning: Double-check the partition number before running the delete partition command. Deleted partitions and their data may be difficult or impossible to recover.
7. Clean a Disk
The clean command removes all partitions and volume information from the selected disk, returning it to an uninitialized state. It’s commonly used before reinstalling Windows, reusing a drive, or converting a disk between MBR and GPT.
Warning: The clean command removes all partition information from the selected disk. Make sure you’ve selected the correct disk before continuing.
To view available disks: list disk
Select the disk you want to erase by replacing X with the disk number: select disk X
Run the following command to clean the disk: clean
After the command completes, the disk will show as Unallocated in Disk Management. You can then create new partitions or convert the disk to a different partition style.
Clean vs. Clean All
cleanRemoves the partition table and volume information. The data is not immediately overwritten and may be recoverable using data recovery software.clean allwrites zeros to every sector on the disk, securely erasing all data. This process can take significantly longer, especially on large drives.
Use clean all only when you need to securely erase a disk before selling, recycling, or repurposing it.
8. Convert a Disk Between MBR and GPT
DiskPart can convert a disk between the Master Boot Record (MBR) and GUID Partition Table (GPT) partition styles. This is useful when preparing a drive for a Windows installation or when changing a disk’s partition scheme.
Important: The disk must not contain any partitions. If necessary, use the clean command first. Back up your data before proceeding, as cleaning the disk removes all partition information.
To convert a disk to GPT:
list disk
select disk X
clean
convert gpt

To convert a disk to MBR:
list disk
select disk X
clean
convert mbr
After the conversion is complete, create a new partition, format it, and assign a drive letter before using the disk.
Tip: For modern Windows 11 systems that use UEFI, GPT is the recommended partition style. MBR is mainly used for older computers that boot in Legacy BIOS mode.
DiskPart vs. Disk Management
Both DiskPart and Disk Management can create, delete, format, and manage disk partitions. The main difference is how you interact with them and the level of control they provide.
| Feature | DiskPart | Disk Management |
|---|---|---|
| Interface | Command-line | Graphical (GUI) |
| Ease of use | Best for advanced users | Beginner-friendly |
| Create, delete, and format partitions | ✓ | ✓ |
| Extend and shrink partitions | ✓ | ✓ |
| Convert MBR and GPT | ✓ | ✓ (empty disks only) |
| Automation with scripts | ✓ | ✗ |
| Available in Windows Recovery Environment (WinRE) | ✓ | ✗ |
| Risk of accidental changes | Higher | Lower |
For most everyday tasks, Disk Management is easier to use because it provides a visual interface and is less prone to mistakes. However, DiskPart is the better choice when you need advanced disk management features, are troubleshooting storage problems, or are working in the Windows Recovery Environment (WinRE), where the graphical tool isn’t available.
Frequently Asked Questions
Yes, DiskPart is safe when used correctly. However, it executes commands immediately without asking for confirmation in many cases. Always verify that you’ve selected the correct disk or partition before running commands such as clean, delete partition, or format, as these operations can permanently erase data.
It depends on the command you use. Commands like clean, delete partition, and format remove partition information or erase data on the selected partition. Other commands, such as list disk or list volume, only display information and don’t modify your storage devices.
The DiskPart convert gpt command requires the disk to be empty, so you’ll typically need to run the clean command first, which removes all partitions. If you want to convert a system disk without deleting data, use Microsoft’s MBR2GPT tool instead.
To close DiskPart, type the command exit and press Enter: This returns you to the Command Prompt or Windows Terminal.
If DiskPart doesn’t detect your drive, check that it’s properly connected and powered on. You should also verify that the drive appears in your computer’s BIOS/UEFI firmware and in Device Manager. If it still isn’t detected, the drive or its connection may have a hardware issue.
