Diskpart Commands: A Practical Windows Guide to Disk Management

Saipansab Nadaf Written by Saipansab Nadaf
Updated on
Aug 06, 2026

Whether you are setting up a new SSD, fixing a corrupted USB drive, or preparing a drive for Windows installation, Diskpart commands give you more control than the standard Disk Management tool.

It allows you to create, format, delete, and manage partitions directly from the command line, making it a favorite among IT professionals and power users.

However, because every command runs directly on the selected disk, one mistake can erase your data. This guide explains the most useful Diskpart command lines and how to work with them safely.

What is Diskpart Command?

Diskpart cmd is a built-in Windows command-line utility that helps you manage disks, partitions, volumes, and virtual hard disks. Instead of using the graphical tool, you control storage devices by entering commands in Command Prompt, Windows Terminal, or PowerShell.

Diskpart in Command Prompt

Diskpart tool performs actions directly on the selected storage device. This makes it especially useful for advanced disk management, troubleshooting, and automation. 

Before running disk management commands, you need to select the disk, partition, or volume you want to work with. This selected item becomes the current focus, and every command you enter afterward applies only to it.

Some common uses of the Windows Disk Management command line include:

  • Initializing a new HDD or SSD.
  • Creating, deleting, or recovering partitions
  • Formatting an SSD and other storage devices
  • Assigning or changing drive letters
  • Managing virtual hard disks
  • Troubleshooting storage issues that Disk Management can’t resolve

Important: Disk commands such as clean and format can permanently remove data, so double-check the selected disk and back up important files before making changes.

How to Open Diskpart in Windows?

Diskpart comes pre-installed with Windows, so you don’t need to download or install anything. Here’s how to open it:

  • Press Windows + S and search for Command Prompt or PowerShell.
  • Right-click the application and select Run as administrator.
    Run Command Prompt as administrator
  • If the User Account Control prompt appears, click Yes.
  • Now, type “diskpart” and press Enter
  • If Diskpart launches successfully, you will see the prompt change to “DISKPART>”. You can now start entering the disk management command line.
    Run diskpart
  • If you are unsure about a command or its syntax, you can use diskpart help by using “help”.
    Diskpart help command
  • To learn more about a specific command, type help followed by its name. For example:
    help format

    Or

    help clean

    Diskpart will display a description of the command along with its available options.

Microsoft recommends using Diskpart with administrator privileges because many CMD Disk Management operations require elevated permissions.

Most Useful Windows Diskpart Commands (With Examples)

Diskpart includes dozens of commands, but you will only need a few for most command prompt disk management tasks. Below are the ones you will use most often, along with examples.

1. list d\isk

Diskpart lists disks connected to your computer.

list disk

Run the list disk command to identify the correct disk by checking its number and size.

2. select disk

Select the disk you want to manage.

select disk 1

Replace 1 with the appropriate disk number. Once selected, all subsequent commands apply to that disk.

3. detail disk

Shows detailed information about the selected disk

detail disk

This is useful when multiple drives have similar capacities, as it displays additional hardware details to help confirm you have selected the correct disk.

4. list volume

Lists all volumes available on your system.

list volume

It shows useful information such as drive letters, file systems, labels, and partition sizes.

5. select volume

Selects a specific volume for further actions.

select volume 3

After selecting a volume, any command you run affects only that volume.

6. create partition primary

Creates a primary partition on the selected disk.

create partition primary size=50000

By default, Diskpart uses all available unallocated space. To create a smaller partition, specify the size in megabytes.

7. format

Formats the selected partition with a file system.

format fs=ntfs quick

Common file systems include:

  • NTFS: Best for Windows internal drives.
  • FAT32: Compatible with older devices and operating systems.
  • exFAT: Ideal for USB drives and external storage used across Windows and macOS.

Adding the quick parameter performs a fast format. Otherwise, it runs a full format, which takes longer.

8. assign

Assigns a drive letter to the selected volume.

assign letter=E

Once assigned, the drive becomes accessible in File Explorer.

9. clean

Removes all partition and volume information from the selected disk.

clean 

Unlike formatting, clean deletes the disk’s partition structure and leaves it as unallocated space. You will need to create a new partition and format the drive before using it again.

10. exit

This command closes and takes you back to the initial Command Prompt or PowerShell.

exit 

How to Manage Disks Using Diskpart Utility?

Once you understand the basic commands, you can combine them to perform common command-line disk management tasks. The general workflow is simple:

  • Identify the correct disk or volume.
  • Select it.
  • Perform the required operation.
  • Verify the result.

Since every command applies to the currently selected object, always confirm the disk before making changes. Now, let’s take a look at complete commands for some common Diskpart usage.

Initialize and Prepare a New Drive

If you have installed a new HDD or SSD, use the following commands to make it ready to use:

diskpart

list disk

select disk 1

create partition primary

format fs=ntfs quick

assign

exit

Initialize a new drive

This creates a primary partition, formats it with the NTFS file system, and assigns a drive letter so the drive appears in File Explorer.

Wipe a Disk Before Reusing It

When preparing a drive for reuse or a fresh Windows installation, remove its existing partition structure first.

diskpart

list disk

select disk 1

clean

exit

Run the clean command

The clean command deletes all partition information, leaving the disk as unallocated space. To use the drive again, create a new partition, format it, and assign a drive letter.

Change or Assign a Drive Letter

If Windows does not automatically assign a drive letter, you can do it manually.

list volume

select volume 3

assign letter=E

Assigning a drive letter

The volume becomes immediately accessible using the new drive letter.

Diskpart Best Practices, Common Errors, and Troubleshooting

Diskpart is reliable, but it performs commands exactly as entered. Following a few best practices can help prevent costly mistakes.

Best Practices

  • Run Command Prompt or PowerShell as Administrator.
  • Use a list disk and verify the disk size before selecting a drive.
  • Back up important data before using commands like clean or format.
  • Review each command before pressing Enter.
  • Use the help command if you are unsure about a command’s syntax.

Common Errors 

  • Access is denied: Diskpart was not started with administrator privileges. Just close the terminal, reopen it as Administrator, and try again.
  • No fixed disks to show:  Windows is not detecting the storage device. Check the drive connection, reconnect the device if necessary, or verify that it is detected in your BIOS/UEFI settings.
  • Selected the wrong disk: Compare the disk number and storage size before using commands like clean or format to avoid erasing the wrong drive.
  • Drive is not visible after using clean: This is normal; you don’t have to panic. Just create a new partition, format it, and assign a drive letter to use the drive again.

By following these tips and knowing how to resolve common errors, you can use Diskpart more safely and reduce the risk of accidental data loss.

Wrapping Up

Diskpart is one of the most powerful storage management tools built into Windows. It gives you precise control over disks, partitions, and volumes, making it useful for everything from preparing a new SSD to troubleshooting storage issues and automating deployment tasks.

For everyday partitioning and formatting, Disk Management is usually the easier choice. But when you need advanced control or command-line automation, Diskpart remains the better tool.

Frequently Asked Questions

What does Diskpart do in Windows?

Ans. It is a built-in Windows command-line tool that lets you create, delete, format, and manage disks, partitions, volumes, and virtual hard disks.

How do I see all disks in Diskpart?

Ans. Run “list disk” to display all connected storage devices along with their disk numbers, sizes, and available space.

Are Diskpart format commands safe to use?

Ans. Yes, as long as you have selected the correct disk or partition. Since formatting erases data, verify your selection and back up important files beforehand.

What is the difference between clean and format?

Ans. The clean command removes a disk’s partition information, leaving it as unallocated space. The format command prepares an existing partition with a file system like NTFS, FAT32, or exFAT so it can store data.

Can Diskpart repair a damaged disk?

Ans. Diskpart can resolve partition and drive configuration issues, such as recreating partitions or assigning drive letters. However, it cannot repair physical hardware damage or recover a failing drive. 

Sources
Related Posts
Operating System Sep 18, 2026
How to Restart Bluetooth Service Windows 11? (Fix Bluetooth Issues)

Bluetooth stopped working in Windows 11? It can suddenly stop working even when your headphones, mouse, or keyboard work perfectly…

How to Fix External Hard Drive Not Showing Up in Windows?
Operating System Sep 17, 2026
How to Fix External Hard Drive Not Showing Up in Windows?

You plug in your external hard drive, wait for Windows to recognize it, and then… nothing pops up. The drive…

system service exception
Operating System Sep 14, 2026
How to Fix the System Service Exception BSOD Error in Windows

A sudden Windows blue screen can bring everything to a stop, and the System Service Exception error does not tell…

macos compatibility
Operating System Sep 09, 2026
macOS Compatibility Guide: What macOS Can My Mac Run?

Trying to update an older Mac can leave you with one simple question: what version of macOS can my Mac…

check how much ram you have
Operating System Sep 08, 2026
How to Check How Much RAM You Have on Windows and Mac?

How much RAM do I have? Not sure whether your computer has 4 GB, 8GB, 16GB, or more RAM? You…

vcruntime140 dll not found
Operating System Sep 08, 2026
VCRUNTIME140.dll Not Found: How to Fix the Error in Windows

You open an app expecting it to work, only to see a cryptic message saying: VCRUNTIME140.dll not found. In most…

Split Screen on Windows Laptops
Operating System Sep 02, 2026
How to Split Screen on Windows Laptops?

Working with two apps at once is much easier when you don’t have to keep switching between them. Windows has…

this app has been blocked for your protection
Operating System Aug 31, 2026
How to Fix “This App Has Been Blocked for Your Protection” in Windows?

You open an app, and Windows stops you with a red warning: This app has been blocked for your protection.…

mbs to gpt without loss
Operating System Aug 24, 2026
How to Convert MBR to GPT Without Data Loss in Windows?

You don’t need to wipe your Windows drive just to change its partition style. Microsoft’s MBR2GPT Windows 10/11 tool can…