robot TL;DR:

Diskpart is a built-in Windows command-line utility that allows users to manage, format, shrink, and convert local and external disk partitions directly through an Administrator-level Command Prompt.
    ● Executing actions requires a strict command sequence where users must identify and isolate the target drive using the list disk and select disk commands before applying modifications to prevent data loss on the wrong volume.
    ● Converting a drive between MBR and GPT partition styles requires first executing the clean command on the selected disk, which entirely wipes all existing partitions and data.
    ● The utility lacks warning prompts for destructive commands like format or clean all, requiring users to rely on external recovery software like Recoverit if a partition table is unintentionally deleted.


Ask AI for a summary

DiskPart is a Microsoft command-line utility for managing disks, partitions, volumes, and virtual hard disks in Windows. It is powerful because it can create, format, extend, shrink, assign drive letters, convert partition styles, and erase disks from a command prompt.

That power also makes DiskPart risky. It works on the object currently in focus, such as the selected disk, selected partition, or selected volume. If you select the wrong target before running clean, format, or delete partition, you can lose data immediately.

This guide should separate read-only commands from commands that change or erase storage, then show safer Windows 11/10 command sequences for common partition tasks.

note
Note: Do not test DiskPart commands on a disk that contains important files. Back up data first or practice on an empty USB drive.

Before You Run DiskPart Commands: Safety Checklist

Safety Check Why It Matters Command or Action
Run as administrator DiskPart needs elevated permission for most storage changes Open Terminal or Command Prompt as administrator
List disks and volumes first Prevents selecting the wrong drive list disk and list volume
Confirm the focused object DiskPart commands act on the selected disk, volume, or partition detail disk, detail volume, or detail partition
Back up important files Format, clean, delete, and convert commands can remove data Copy files to another drive before making changes
Check the disk number by size USB, SD cards, external drives, and internal disks can look similar Compare size, status, and drive letter before selecting
Avoid destructive commands on system disk Wrong commands can make Windows unbootable Do not run clean, delete, or format on the OS disk unless reinstalling intentionally

Part 1. What Is DiskPart?

DiskPart is a built-in Microsoft command interpreter for disk, partition, volume, and virtual disk management. It replaced older tools such as Fdisk for many command-line disk management tasks.

Item DiskPart Details
Developer Microsoft
Tool type Command-line disk partitioning and volume management utility
Best for Advanced disk operations, scripting, recovery environments, USB preparation, drive letter fixes, and partition repair tasks
Works with Disks, partitions, volumes, virtual hard disks, removable storage, and external drives recognized by Windows
Requires Administrator permission for most changes
Key rule Most commands require selecting a disk, partition, or volume before making changes

Disk Management is easier for visual tasks. DiskPart is better when the graphical tool is unavailable, Windows cannot assign a drive letter correctly, a script is required, or the user is working in Windows Recovery Environment.

Part 2. Common DiskPart Commands in Windows 11/10

The most important DiskPart concept is focus. You normally run a list command, select the correct disk, volume, or partition, confirm it with a detail command, and only then run the action command.

Command Purpose Data Risk
list disk Displays disks detected by Windows Read-only
list volume Displays volumes and drive letters Read-only
list partition Displays partitions on the selected disk Read-only
list vdisk Displays virtual disks Read-only
select disk n Sets the target disk focus Safe by itself, risky before destructive commands
select volume n Sets the target volume focus Safe by itself, risky before destructive commands
select partition n Sets the target partition focus Safe by itself, risky before destructive commands
detail disk, detail volume, detail partition Shows detailed information about the selected object Read-only
assign letter=E Assigns a drive letter to the selected volume Low
remove letter=E Removes a drive letter from the selected volume Medium if apps depend on the letter
create partition primary size=102400 Creates a primary partition of a specified size in MB Medium if the wrong disk is selected
format fs=ntfs quick Formats the selected volume with a file system High, removes existing file references
extend size=10240 Extends the selected volume into available contiguous free space Medium
shrink desired=10240 Shrinks the selected volume by the specified size in MB Medium
delete partition Deletes the selected partition High, removes partition access
clean Removes partition and volume information from the selected disk Very high
clean all Writes zeros to every sector of the selected disk Extreme and slow, destroys recoverability
convert gpt or convert mbr Converts the selected empty disk partition style High if cleanup is required first
active Marks the selected MBR partition as active High on boot disks if used incorrectly

DiskPart Command Risk Levels

Risk Level Commands Rule Before Running
Read-only list, detail, help Safe for diagnosis
Low assign, attributes volume clear readonly Confirm the selected volume first
Medium shrink, extend, remove letter, create partition Back up important data and check available space
High format, delete partition, active, convert mbr, convert gpt Back up or recover data first and confirm target with detail
Extreme clean, clean all Use only when intentionally erasing or resetting the selected disk

Part 3. DiskPart Command Examples to Manage Partitions in Windows

DiskPart commands are entered one line at a time. Press Enter after each command and read the output before continuing. For every task, identify the target first, select it, confirm it, then run the action command.

Example 1: Mark an MBR Partition as Active

The active command should be used only on an MBR disk partition that must be used for BIOS-style booting. Do not use it casually on GPT disks or random data partitions.

  1. Run diskpart.
  2. Run list disk.
  3. Run select disk n and replace n with the correct disk number.
  4. Run detail disk to confirm the selected disk.
  5. Run list partition.
  6. Run select partition n and replace n with the target MBR partition.
  7. Run detail partition to confirm the selected partition.
  8. Run active only if you are certain this partition should be active.
make disk active
note
Note: Marking the wrong partition active can make a BIOS-based PC fail to boot. On modern UEFI/GPT systems, do not use active as a general boot repair command.

Example 2: Assign a Drive Letter to a Volume

Use assign when a partition or removable drive appears in Disk Management but has no drive letter in File Explorer.

  1. Run diskpart as administrator.
  2. Run list volume.
    type list volume
  3. Find the target volume by size, label, and file system.
  4. Run select volume n.
    select the volume number
  5. Run detail volume to confirm it is the correct volume.
  6. Run assign letter=E and replace E with an unused drive letter.
    assign letter via diskpart
  7. Open File Explorer and check whether the volume appears.
note
Note: Avoid changing drive letters used by installed apps, games, scripts, or backup jobs unless you are ready to update those paths.

Example 3: Create, Assign, and Format a New Primary Partition

Use this sequence only on unallocated space or on a disk that you intentionally prepared for a new partition. Creating and formatting the wrong partition can remove access to existing data.

  1. Run diskpart.
  2. Run list disk.
  3. Run select disk n.
  4. Run detail disk and confirm the selected disk.
  5. Run create partition primary size=102400 to create a 100GB partition, or omit size to use all available space.
  6. Run format fs=ntfs quick label=Data, or choose fs=exfat for cross-device removable storage.
  7. Run assign letter=E.
  8. Run exit.
create primary partition
note
Note: For USB drives, SD cards, cameras, and game consoles, use the file system required by the target device. NTFS, exFAT, and FAT32 are not interchangeable for every device.

Example 4: Delete a Partition

The delete partition command removes the selected partition. If you delete the wrong partition, stop immediately and do not create a new partition, format the disk, or write new data before recovery.

  1. Back up or recover data from the partition first.
  2. Run diskpart.
  3. Run list disk.
  4. Run select disk n.
  5. Run list partition.
  6. Run select partition n.
  7. Run detail partition.
  8. Run delete partition only after confirming the target.
delete partition command
note
Note: Some protected partitions may require special handling. Do not delete EFI, Recovery, MSR, or OEM partitions unless you know exactly why they are safe to remove.

Example 5: Format a Volume

The format command prepares a selected volume with a file system. It removes existing file references from that volume, so recover or back up important files first.

  1. Run diskpart.
  2. Run list volume.
  3. Run select volume n.
  4. Run detail volume to confirm the drive letter, size, and label.
  5. Run format fs=ntfs quick label=Data for a quick NTFS format.
  6. Use format fs=exfat quick when the target device requires exFAT.
    format partition command
  7. Run assign letter=E if the volume needs a drive letter.
note
Note: A quick format is faster but still removes normal file access. A full format can make recovery harder and takes much longer.

Example 6: Shrink a Volume

Use shrink to reduce a selected volume and create unallocated space. The size is entered in MB, and Windows may limit shrink size because of unmovable files.

  1. Back up important files from the volume.
  2. Run diskpart.
  3. Run list volume.
  4. Run select volume n.
  5. Run detail volume.
  6. Run shrink querymax to check the maximum reclaimable size.
  7. Run shrink desired=10240 to shrink by 10GB.
shrink partition command

Example 7: Extend a Volume

Use extend to add available unallocated space to the selected volume. In many cases, the unallocated space must be immediately after the target volume.

  1. Back up important data.
  2. Run diskpart.
  3. Run list volume.
  4. Run select volume n.
  5. Run detail volume.
  6. Run extend size=10240 to extend by 10GB, or run extend to use all available compatible space.
  7. Run list volume again to confirm the new size.

Example 8: Clean or Erase a Disk

clean and clean all are high-risk commands. Use them only when you intentionally want to reset or erase the selected disk.

Command What It Does Recovery Impact
clean Removes partition and volume information from the selected disk Data may still be recoverable if no new data is written
clean all Writes zeros to every sector of the selected disk Recovery is usually not practical because data is overwritten
  1. Back up or recover all needed data first.
  2. Run diskpart.
  3. Run list disk.
  4. Run select disk n.
  5. Run detail disk and confirm size, model, and volumes.
  6. Run clean only if you want to remove partition information.
  7. Run clean all only if you intentionally want to overwrite the whole disk.
clean up or erase disk command
note
Note: If you accidentally ran clean, stop using the disk immediately. Do not create a new partition or format it before attempting partition recovery.

Example 9: Convert Between MBR and GPT

DiskPart convert gpt and convert mbr are intended for selected empty disks. Many guides use clean before conversion, but that removes partition information and can cause data loss.

  1. Back up the entire disk.
  2. Use this sequence only on a disk you are willing to erase.
  3. Run diskpart.
  4. Run list disk.
  5. Run select disk n.
  6. Run detail disk.
  7. Run clean only after confirming data is backed up.
  8. Run convert gpt or convert mbr.
mbr to gpt command
note
Note: For a Windows system disk that must be converted from MBR to GPT without wiping data, review Microsoft MBR2GPT.EXE instead of using DiskPart clean.

Part 4. How To Open DiskPart in Windows 11/10

Open DiskPart with administrator permission. If Windows cannot boot, you can also open Command Prompt from Windows Recovery Environment and run DiskPart there.

Method Steps Best For
Windows Terminal Right-click Start, choose Terminal Admin, type diskpart, and press Enter Windows 11 and newer Windows 10 builds
Command Prompt Search cmd, choose Run as administrator, type diskpart, and press Enter Classic Windows command workflow
Run dialog Press Windows + R, type diskpart, and approve administrator prompt Fast launch when Windows is working
Windows Recovery Environment Open Troubleshoot > Advanced options > Command Prompt, then run diskpart Boot repair, offline disk checks, and recovery tasks
note
Note: In recovery environments, disk numbers and drive letters may differ from normal Windows. Always run list disk, list volume, and detail again.

Part 5. Recover Data After Wrong DiskPart Commands

If a wrong DiskPart command deleted a partition, formatted a volume, or ran clean on the wrong disk, stop using that disk immediately. Do not create a new partition, format the disk again, or copy new files to it.

Wondershare Recoverit can scan disks, partitions, external drives, USB drives, memory cards, and other storage devices for recoverable files after accidental deletion, formatting, partition loss, or a DiskPart mistake. Recovery is much harder after clean all because that command overwrites sectors with zeros.

Free Download
Free Download
DiskPart Mistake What To Do Immediately Recovery Chance
Ran delete partition Stop using the disk and scan the original drive Often possible if no new partition or format was created
Ran format quick Stop writing data and scan the formatted volume Possible if data was not overwritten
Ran clean Do not initialize, partition, or format the disk Possible in some cases before overwrite
Ran clean all Stop immediately and evaluate whether any backup exists Very low because data is overwritten
Converted the wrong disk after clean Stop using the disk and scan before creating volumes Depends on overwrite and new partition creation
  1. Stop using the affected disk.
  2. Install Wondershare Recoverit on another drive or another computer if possible.
    launching recoverit for partition recovery
  3. Open Recoverit and select the affected disk, lost partition, or formatted volume.
  4. Start the scan.
    scanning deleted partitions
  5. Preview recoverable files.
    previewing via recoverit
  6. Click Recover.
  7. Save recovered files to a different disk.
note
Note: Never save recovered files back to the same disk that was deleted, formatted, or cleaned by DiskPart.
Free Download
Free Download

Conclusion

DiskPart is a powerful Windows 11/10 tool for managing disks, partitions, volumes, and virtual disks. Use read-only commands such as list disk, list volume, list partition, and detail to understand the storage layout before making changes.

For routine tasks, DiskPart can assign drive letters, create partitions, format volumes, shrink or extend volumes, and prepare USB or external drives. For high-risk tasks, treat delete partition, format, clean, clean all, and convert mbr or convert gpt with caution because they can remove data or make a disk unbootable.

If a wrong DiskPart command causes partition loss or data loss, stop using the affected disk immediately and scan it with Wondershare Recoverit before creating new partitions or saving new data.

FAQ

  • Do I need to install Diskpart from any external source?
    No! Diskpart is a Windows utility already installed and incorporated into your operating system. You don't need to install it from any external source, nor does it cost you.
  • Does the Diskpart Clean command delete all the hard drive data?
    The Clean command enables you to delete any or all drive partitions. However, all the data won't be deleted; if you have cleaned only one drive, the data associated with that drive will be deleted.
  • Does older Windows versions include Diskpart?
    No! Earlier Windows OS versions had the Fdisk tool instead of Diskpart to manage hard drives and partitions.
  • I accidentally lost a partition by entering the wrong command in Diskpart; what to do next?
    The lost partition is only removed from the record of the partition table and is not entirely gone. Therefore, if you have accidentally lost your partition, you can recover it using dependable recovery software.
  • Can I format my disk using Diskpart?
    Yes! Diskpart allows you to format any or all of your disks; you can accomplish this by applying the "format" command to the specified drive. Note that formatting deletes all the drive content, so back up your data into another drive before formatting.
David Darlington
David Darlington Jul 21, 26
Share article:
Get Recoverit Get Recoverit