CMD Simulator
Disk Managementdiskpart

Diskpart Command: Disk Partition Management Tool | Windows Guide

Learn how to use diskpart to manage disks, partitions, and volumes in Windows. Complete guide with examples, disk cleaning, formatting, and troubleshooting.

Rojan Acharya·
Share

The diskpart command is a Windows Command Prompt utility that manages disks, partitions, and volumes through a powerful command-line interface for operations beyond the GUI Disk Management tool. Use diskpart to clean disks completely, create and format partitions, convert between disk types (MBR/GPT), manage RAID volumes, and recover from partition corruption when GUI tools fail.

Whether you're an IT professional preparing USB installation media, a system administrator managing server storage arrays, or troubleshooting partition table corruption that prevents Windows from booting, diskpart provides low-level disk operations essential for advanced storage management. System administrators rely on diskpart for scripted disk provisioning, emergency recovery when Disk Management won't load, and operations like clean disk wipes that GUI tools deliberately restrict for safety.

This comprehensive guide covers diskpart command syntax, all major disk operations, practical examples for partitioning and formatting tasks, critical safety warnings to prevent data loss, troubleshooting tips for partition issues, related storage commands, and frequently asked questions. By the end, you'll confidently manage Windows storage from the command line while understanding the significant risks involved.

What Is the Diskpart Command?

The diskpart command is Microsoft's command-line disk partitioning utility that operates at a lower level than GUI tools, providing complete control over disk structures including partition tables, volume labels, drive letters, and file systems. Diskpart works directly with disk hardware through device drivers, bypassing many safety checks that GUI tools enforce.

Diskpart runs on all Windows versions from XP through 11, including Server editions. The command requires administrator privileges and operates in an interactive shell mode—you type diskpart to enter the utility, then issue commands within the diskpart> prompt. This design prevents accidental one-line data destruction while providing powerful scripting capabilities.

WARNING: Diskpart operations are immediate and irreversible. Commands like clean permanently erase all data on selected disks without confirmation prompts. Always verify disk selection with list disk and confirm the correct disk is selected before destructive operations. Incorrect disk selection can destroy your operating system or all personal data instantly.

Syntax

diskpart
(Interactive mode - enter commands at diskpart> prompt)

Essential Commands

CommandDescription
list diskDisplay all disks on the system
list volumeDisplay all volumes/partitions
select disk NSelect disk N for operations
select volume NSelect volume N for operations
cleanDANGER: Erase all data on selected disk
create partition primaryCreate primary partition on selected disk
format fs=ntfs quickQuick format selected volume as NTFS
assign letter=XAssign drive letter X to selected volume
activeMark selected partition as active (bootable)
extendExtend selected volume into adjacent free space
shrinkShrink selected volume to create free space
convert gptConvert disk from MBR to GPT
convert mbrConvert disk from GPT to MBR

Parameters Explained

list disk – Display All Disks

The list disk command shows all physical and virtual disks attached to the system with size, status, and GPT/MBR type. This is the essential first command before any disk operation.

Example: list disk

Output shows disk numbers, size, free space, dynamic/basic status, and GPT marker. Always verify disk numbers before selection—disk numbering can change between reboots or when drives are connected/disconnected.

clean – Complete Disk Wipe

EXTREME DANGER: The clean command permanently erases all partitions, volumes, and data from the selected disk by zeroing the partition table. Recovery is extremely difficult or impossible without specialized forensic tools.

Example: clean

This operation is immediate and irreversible. No confirmation prompt appears. Use only on disks you absolutely intend to completely erase. Common use: preparing USB drives for fresh formatting or securely wiping disks before disposal.

create partition – New Partition Creation

Creates a new partition on the selected disk. Specify primary for bootable/standard partitions, extended for extended partitions containing logical drives, or logical for logical drives within extended partitions.

Example: create partition primary size=102400

Creates a 100GB primary partition (size in megabytes). Omit size to use all available space.

format – Volume Formatting

Formats the selected volume with a specified file system. Supports NTFS, FAT32, exFAT, and ReFS on supported Windows versions. The quick parameter performs fast formatting; omit for full format with bad sector checking.

Example: format fs=ntfs label="Data" quick

Formats as NTFS with volume label "Data" using quick format.

Examples

View All Disks and Partitions

Scenario: Before any disk operations, you need to identify which physical disk and partitions are present on the system to avoid accidentally selecting the wrong disk.

diskpart
list disk
list volume

Expected Output:

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          238 GB      0 B        *
  Disk 1    Online          931 GB   931 GB

DISKPART> list volume

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     C   Windows      NTFS   Partition    237 GB  Healthy    Boot
  Volume 1     D                       CD-ROM          0 B  No Media

Explanation: list disk shows physical disks (Disk 0 is Windows SSD with GPT, Disk 1 is empty data drive). list volume shows logical volumes (C: is Windows boot volume). Always verify disk numbers before operations.

Create and Format New Partition

Scenario: You've installed a new hard drive (Disk 1) and need to create a partition, format it as NTFS, and assign drive letter E: for data storage.

diskpart
select disk 1
create partition primary
format fs=ntfs label="Data" quick
assign letter=E

Expected Output:

DISKPART> select disk 1
Disk 1 is now the selected disk.

DISKPART> create partition primary
DiskPart succeeded in creating the specified partition.

DISKPART> format fs=ntfs label="Data" quick
  100 percent completed
DiskPart successfully formatted the volume.

DISKPART> assign letter=E
DiskPart successfully assigned the drive letter or mount point.

Explanation: This complete workflow partitions, formats, and makes the new drive accessible. The partition uses all available space since no size was specified.

Clean and Prepare USB Drive

Scenario: You need to create a bootable USB drive for Windows installation, but the USB has existing partitions that interfere. You must completely clean the drive first.

⚠️ WARNING: This erases ALL data on the USB drive permanently!

diskpart
list disk
select disk 2
clean
create partition primary
format fs=fat32 quick
assign
active

Expected Output:

DISKPART> list disk
  Disk ###  Status         Size     Free     Dyn  Gpt
  Disk 0    Online          238 GB      0 B        *
  Disk 1    Online          931 GB      0 B
  Disk 2    Online           28 GB      0 B

DISKPART> select disk 2
Disk 2 is now the selected disk.

DISKPART> clean
DiskPart succeeded in cleaning the disk.

DISKPART> create partition primary
DiskPart succeeded in creating the specified partition.

DISKPART> format fs=fat32 quick
  100 percent completed
DiskPart successfully formatted the volume.

DISKPART> assign
DiskPart successfully assigned the drive letter or mount point.

DISKPART> active
DiskPart marked the current partition as active.

Explanation: Verify with list disk that Disk 2 is the USB (check size). clean wipes everything, then we create a primary partition, format as FAT32 (required for UEFI boot media), assign automatic drive letter, and mark active for bootable status.

Convert Disk from MBR to GPT

Scenario: You're upgrading to UEFI firmware and need to convert your data disk from MBR (Master Boot Record) to GPT (GUID Partition Table) to support drives larger than 2TB.

⚠️ WARNING: Converting erases all data! Backup first!

diskpart
list disk
select disk 1
clean
convert gpt

Expected Output:

DISKPART> select disk 1
Disk 1 is now the selected disk.

DISKPART> clean
DiskPart succeeded in cleaning the disk.

DISKPART> convert gpt
DiskPart successfully converted the selected disk to GPT format.

Explanation: clean is required before conversion—you cannot convert disks with existing partitions. After conversion to GPT, recreate partitions and restore data from backup.

Extend Volume into Free Space

Scenario: Your C: drive (Volume 0) is running low on space. You have unallocated space immediately following the C: partition and want to expand C: into that space.

diskpart
list volume
select volume 0
extend

Expected Output:

DISKPART> select volume 0
Volume 0 is the selected volume.

DISKPART> extend
DiskPart successfully extended the volume.

Explanation: extend adds all contiguous unallocated space to the selected volume. The free space must be immediately adjacent (to the right of) the volume you're extending, and both must be on the same disk.

Shrink Volume to Create Free Space

Scenario: You need to create unallocated space for a new partition, so you'll shrink your large D: drive (Volume 2) to free up 50GB.

diskpart
list volume
select volume 2
shrink desired=51200

Expected Output:

DISKPART> select volume 2
Volume 2 is the selected volume.

DISKPART> shrink desired=51200
DiskPart successfully shrunk the volume by:  51200 MB

Explanation: Shrinks Volume 2 by 50GB (51200 MB), creating 50GB of unallocated space. The actual amount shrunk may be less if unmovable files prevent shrinking the desired amount.

Remove Drive Letter

Scenario: You have a recovery partition that you don't want visible in File Explorer, so you'll remove its drive letter to hide it from normal user access.

diskpart
list volume
select volume 3
remove

Expected Output:

DISKPART> select volume 3
Volume 3 is the selected volume.

DISKPART> remove
DiskPart successfully removed the drive letter or mount point.

Explanation: remove removes the drive letter, making the volume inaccessible from File Explorer but leaving data intact. Useful for hiding recovery partitions or system reserved volumes.

Assign Specific Drive Letter

Scenario: You want a data drive to always appear as drive E: regardless of what other drives are connected to the system.

diskpart
list volume
select volume 4
assign letter=E

Expected Output:

DISKPART> select volume 4
Volume 4 is the selected volume.

DISKPART> assign letter=E
DiskPart successfully assigned the drive letter or mount point.

Explanation: Assigns specific drive letter E: to the selected volume. If E: is already in use, the command fails. Use remove on the existing volume using E: first, then assign it to the desired volume.

Create Multiple Partitions

Scenario: You have a 500GB disk and want to create three partitions: 100GB for OS, 200GB for programs, and remaining space for data.

diskpart
select disk 1
clean
create partition primary size=102400
format fs=ntfs label="OS" quick
assign letter=C
create partition primary size=204800
format fs=ntfs label="Programs" quick
assign letter=D
create partition primary
format fs=ntfs label="Data" quick
assign letter=E

Expected Output: Three partitions created, formatted, and assigned drive letters C:, D:, and E:.

Explanation: Each create partition primary command creates a partition sequentially. First two specify size in MB (100GB = 102400MB, 200GB = 204800MB). Final partition omits size to use all remaining space.

Display Detailed Disk Information

Scenario: You need comprehensive information about a specific disk including manufacturer, model, serial number, and technical specifications.

diskpart
select disk 0
detail disk

Expected Output:

DISKPART> detail disk

Samsung SSD 850 EVO 250GB
Disk ID: 2B5F9C8A
Type   : SATA
Status : Online
Path   : 0
Target : 0
LUN ID : 0
Location Path : PCIROOT(0)#PCI(1F02)#ATA(C00T00L00)
Current Read-only State : No
Read-only : No
Boot Disk : Yes
Pagefile Disk : Yes
Hibernation File Disk : No
Crashdump Disk : Yes
Clustered Disk : No

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     C   Windows      NTFS   Partition    237 GB  Healthy    System

Explanation: detail disk shows comprehensive disk information including hardware details, status flags, and all volumes on the disk. Essential for hardware inventory and troubleshooting.

Common Use Cases

  1. Bootable USB Drive Creation: Clean and format USB drives for Windows installation media, system recovery tools, or bootable diagnostic utilities requiring complete disk wipes and specific partition configurations.

  2. New Disk Initialization: Prepare newly installed hard drives or SSDs by creating partition tables, primary partitions, formatting with NTFS or ReFS, and assigning drive letters for immediate use.

  3. Partition Table Corruption Recovery: When Disk Management GUI fails to load due to corrupted partition tables, use diskpart for emergency disk access, partition recreation, and data recovery attempts.

  4. MBR to GPT Conversion: Convert disk partition schemes for UEFI compatibility, support for drives larger than 2TB, or enabling features like Secure Boot that require GPT partition tables.

  5. Volume Extension for Low Disk Space: Expand system or data volumes into adjacent unallocated space when drives run low on capacity, often after deleting unused partitions or shrinking other volumes.

  6. Multi-Boot Configuration: Create and manage multiple partitions for dual-boot or multi-boot systems, setting active flags appropriately for boot loader configuration across different operating systems.

  7. Disk Sanitization Before Disposal: Securely wipe enterprise drives before decommissioning using clean all for complete data destruction that prevents data recovery from discarded hardware.

  8. RAID and Dynamic Disk Management: Create, extend, and manage dynamic volumes including spanned, striped (RAID 0), mirrored (RAID 1), and RAID-5 volumes on server systems requiring advanced storage configurations.

  9. Recovery Partition Management: Hide or unhide recovery partitions by removing or assigning drive letters, preventing accidental user modification of critical system recovery data.

  10. Fixed Drive Letter Assignment: Ensure specific volumes always receive designated drive letters regardless of connection order, critical for applications with hardcoded paths and server storage configurations.

  11. Emergency Disk Operations: When booted from Windows installation media or recovery environment, use diskpart to repair boot partitions, recreate BCD stores, or rebuild partition structures.

  12. Scripted Disk Provisioning: Automate disk preparation for enterprise deployment by creating diskpart scripts that standardize partition layouts across hundreds of identical systems.

Tips and Best Practices

  1. ALWAYS Verify Disk Selection: Before ANY operation, use list disk and verify disk number, size, and GPT marker. Selecting the wrong disk destroys your Windows installation or personal data instantly. Disk numbers change when drives are connected/disconnected.

  2. Backup Before Destructive Operations: Before clean, convert, or any operation that erases data, backup all important files. These operations are immediate and irreversible—there are no "undo" or confirmation prompts in diskpart.

  3. Use 'clean' with Extreme Caution: The clean command permanently erases all partitions and data without confirmation. Triple-check disk selection. For even more secure wiping, use clean all which overwrites every sector (very slow but ensures data cannot be recovered).

  4. Document Partition Layouts: Before major changes, document current partition layout with list volume and screenshots. This documentation is essential for recovery if operations go wrong or you need to recreate the original structure.

  5. Understand MBR vs GPT Implications: MBR supports 4 primary partitions and 2TB maximum disk size. GPT supports 128 partitions and exabytes of storage. Converting between them requires clean, which erases everything. Choose GPT for modern systems.

  6. Test Shrink Operations First: Before shrinking critical volumes like C:, run shrink querymax to see maximum shrinkable space. Windows cannot shrink beyond unmovable files. Defragmentation often increases shrinkable space.

  7. Assign Specific Drive Letters Deliberately: Don't assign system-reserved letters (A: B: for floppies, C: typically for OS). Use letters beyond F: for data drives to avoid conflicts when mapping network drives.

  8. Format with Quick vs Full: quick format is fast but skips bad sector checking. Full format (omit quick) takes much longer but identifies and marks bad sectors. Use full format on new or suspect drives.

  9. Mark Partitions Active Only When Necessary: The active command marks a partition as bootable. Only one partition per disk should be active. Marking the wrong partition active prevents Windows from booting.

  10. Use Diskpart Scripts for Repeatability: Create .txt files containing diskpart commands, then run with diskpart /s script.txt. Essential for consistent disk provisioning across multiple systems or repeatable disaster recovery procedures.

  11. Exit Properly: Always type exit to leave diskpart when finished. This ensures all operations complete and disk metadata is written correctly. Closing the window abruptly can cause disk corruption.

  12. Understand Dynamic vs Basic Disks: Basic disks use standard partitions. Dynamic disks support advanced features like spanned and RAID volumes but have compatibility limitations. Convert to dynamic only when specifically needed for RAID/spanning.

Troubleshooting Common Issues

"The System Cannot Find the File Specified"

Problem: Commands fail with "The system cannot find the file specified" even though you're sure the disk or volume exists.

Cause: Disk or volume is offline, the drive letter is already in use, or the disk has I/O errors preventing access.

Solution:

  • For offline disks: select disk N then online disk
  • For offline volumes: select volume N then online volume
  • Check for hardware errors with attributes disk or attributes volume

Prevention: Verify disk/volume status with list disk or list volume before operations. Address hardware issues before attempting partition operations.

"DiskPart Has Encountered an Error: Access is Denied"

Problem: All diskpart commands fail with "Access is denied" even for read-only operations like list disk.

Cause: Command Prompt not launched with administrator privileges, or disk is locked by another process/application.

Solution:

  • Close diskpart and relaunch Command Prompt as administrator
  • Close applications accessing the disk (file managers, antivirus, disk utilities)
  • Reboot and immediately run diskpart before other applications start

Prevention: Always launch Command Prompt with "Run as administrator" before starting diskpart. Verify window title shows "Administrator."

"The Parameter is Incorrect" or "Invalid Syntax"

Problem: Diskpart commands fail with syntax errors despite appearing correct.

Cause: Extra spaces, typos in keywords, incorrect parameter formats, or attempting operations on incompatible disk types (basic vs dynamic).

Solution:

  • Verify spelling: partition not parttion, primary not primery
  • Check spaces: fs=ntfs not fs= ntfs or fs =ntfs
  • Confirm disk type compatibility: Some commands require basic disks

Prevention: Copy-paste verified working commands from documentation. Use tab completion where available to prevent typos.

Cannot Shrink Volume as Much as Expected

Problem: Running shrink command shrinks volume far less than available free space, or reports "There is not enough space available."

Cause: Unmovable system files (page file, hibernation file, System Restore points, Volume Shadow Copies) are located beyond the shrink boundary, preventing volume reduction.

Solution:

  • Disable hibernation: powercfg /h off (re-enable after: powercfg /h on)
  • Disable System Restore temporarily, shrink, then re-enable
  • Disable page file on the volume, reboot, shrink, then re-enable
  • Delete Volume Shadow Copies with vssadmin delete shadows
  • Defragment the volume thoroughly before shrinking

Prevention: Plan partition layouts in advance. Shrinking is always limited by unmovable files. Creating correct sizes initially avoids these issues.

"The Disk is Offline Because of Policy Set by an Administrator"

Problem: Disk appears in list disk but shows as "Offline" with policy message, preventing all operations.

Cause: SAN policy or Group Policy settings automatically offline certain disk types (typically used in virtualization or SAN environments).

Solution:

diskpart
select disk N
attributes disk clear readonly
online disk

Or modify SAN policy: san policy=onlineall before online disk.

Prevention: Review Group Policy and SAN policy settings in virtualization environments. Configure policies appropriately for your use case (desktop vs server environments).

Accidentally Cleaned Wrong Disk – Data Recovery

Problem: You selected and cleaned the wrong disk, erasing Windows or all personal data. Panic sets in.

Cause: Failed to verify disk selection with list disk before running clean, or misidentified which disk number corresponds to which physical drive.

Solution (Immediate action):

  1. STOP using the computer immediately to prevent overwriting data
  2. Do NOT reinstall Windows or create new partitions—this overwrites data
  3. Download data recovery software on a different computer (TestDisk, DMDE, R-Studio)
  4. Boot from recovery media or remove drive and connect to another system
  5. Use recovery software to scan for and restore lost partitions

Prevention: ALWAYS run list disk and verify disk number, size, and identify target disk carefully. Document which physical drive corresponds to each disk number before operations. Consider disconnecting drives you're not working on during critical operations.

Related Commands

chkdsk – Check Disk

Scans file systems for errors and bad sectors. Run chkdsk before diskpart operations on suspect drives to identify hardware issues that could cause operation failures or data loss.

When to use chkdsk: Before formatting or partitioning disks showing signs of corruption. Run chkdsk D: /f /r to fix filesystem errors and recover bad sectors before diskpart operations.

format – Volume Formatting

Command-line format command available outside diskpart. Less flexible than diskpart's format but useful for quick formats without entering diskpart interactive mode.

When to use format: For simple volume formatting: format D: /fs:ntfs /q /v:Data. Use diskpart's format when performing multi-step disk operations within diskpart session.

Disk Management GUI (diskmgmt.msc)

Windows graphical disk management tool. Safer than diskpart with confirmation prompts and visual disk layout, but less powerful and unavailable during boot/recovery scenarios.

When to use Disk Management: For routine partition operations where GUI convenience outweighs command-line power. Disk Management prevents many dangerous operations diskpart allows.

PowerShell Disk Cmdlets

Modern PowerShell disk management cmdlets (Get-Disk, Initialize-Disk, New-Partition, Format-Volume) provide object-oriented alternatives to diskpart with better scripting integration.

When to use PowerShell: For complex automation requiring object manipulation and pipeline processing. PowerShell cmdlets provide safer error handling and better integration with other PowerShell operations.

wmic diskdrive

Legacy WMIC command for querying disk information. Deprecated in favor of PowerShell's Get-Disk but still available for quick disk hardware queries.

When to use wmic: Quick disk enumeration in environments without PowerShell. Use wmic diskdrive list brief to display all physical drives with basic information.

fsutil

File system utility for advanced file system operations like quota management, USN journal, and sparse file handling. Complements diskpart's partition management with filesystem-level operations.

When to use fsutil: For filesystem-specific operations beyond partition management, such as fsutil fsinfo for filesystem information or fsutil behavior for NTFS behavior settings.

Frequently Asked Questions

What does diskpart clean do?

The diskpart clean command permanently erases all partition tables and data from the selected disk by zeroing the partition table structures. This makes all data on the disk immediately inaccessible and unrecoverable through normal means. There is no confirmation prompt—the operation is immediate and irreversible. Use only on disks you absolutely intend to completely wipe.

How do I format a USB drive using diskpart?

⚠️ This erases all USB data! Steps:

  1. diskpart
  2. list disk (identify USB disk number by size)
  3. select disk N (replace N with USB disk number)
  4. clean (erases all data)
  5. create partition primary
  6. format fs=fat32 quick or format fs=ntfs quick
  7. assign
  8. exit

What is the difference between clean and clean all?

clean quickly erases partition tables, making data inaccessible but potentially recoverable with forensic tools. clean all overwrites every sector on the disk with zeros, ensuring data cannot be recovered—this is extremely slow (hours for large drives) but provides secure data destruction before disposal or repurposing.

Can diskpart damage my computer?

Yes, if used incorrectly. Selecting the wrong disk and running clean instantly destroys all data on that disk, including your Windows installation if you select Disk 0. Diskpart operations are immediate with no undo or confirmation. Always verify disk selection carefully before ANY destructive operation.

How do I convert MBR to GPT without losing data?

You CANNOT convert between MBR and GPT without losing data using diskpart—convert requires clean first, which erases everything. To convert without data loss, use:

  • Windows 10/11 built-in mbr2gpt.exe tool (converts without data loss)
  • Third-party tools like EaseUS Partition Master or MiniTool Partition Wizard
  • Backup all data, convert with diskpart, restore data

Why can't I shrink my C: drive very much?

Unmovable system files (page file, hibernation file, System Restore points, Volume Shadow Copies) prevent shrinking past their location. Solutions:

  • Disable hibernation: powercfg /h off
  • Disable page file temporarily
  • Delete System Restore points and Shadow Copies
  • Defragment thoroughly Run shrink querymax to see actual maximum shrinkable space.

How do I make a partition bootable in diskpart?

Select the partition and run active command:

diskpart
list disk
select disk 0
list partition
select partition 1
active

Only one partition per disk should be marked active. This sets the boot flag but doesn't install a bootloader—you need separate tools for bootloader installation.

Can I use diskpart to recover deleted partitions?

No, diskpart cannot recover deleted partitions. Once a partition is deleted or a disk is cleaned, diskpart has no recovery features. Use specialized data recovery tools like TestDisk, DMDE, or commercial recovery software. The key is to STOP using the disk immediately after accidental deletion to maximize recovery chances.

What does "extend" do in diskpart?

The extend command increases the size of the selected volume by adding adjacent unallocated space. The free space must be immediately contiguous (to the right of) the volume. You cannot extend across another partition—the unallocated space must be touching the volume you're extending.

Is diskpart safe for beginners?

No. Diskpart is a powerful tool with no safety nets, confirmation prompts, or undo capabilities. Mistakes result in immediate, permanent data loss. Beginners should use Windows Disk Management GUI (diskmgmt.msc) which provides safety checks and visual confirmation. Learn diskpart on disposable USB drives or virtual machines before using on systems with important data.

How do I list all partitions on a disk?

diskpart
select disk N
detail disk

Or use: list partition after selecting a disk. Both commands show all partitions on the selected disk with size, type, status, and volume information.

Can diskpart work on external drives?

Yes, diskpart works on all storage devices—internal drives, external USB drives, SD cards, etc. External drives appear in list disk alongside internal drives. Be especially careful with disk selection when external drives are connected to avoid accidentally selecting the wrong disk.

Quick Reference Card

CommandPurposeRisk Level
list diskShow all disksSafe
list volumeShow all volumesSafe
select disk NSelect disk for operationsSafe (selection only)
detail diskShow disk informationSafe
cleanErase entire disk⚠️ EXTREME DANGER
create partition primaryCreate partitionMedium (changes disk)
format fs=ntfs quickFormat volumeHigh (erases data)
assign letter=XAssign drive letterLow
removeRemove drive letterLow
extendGrow volumeMedium
shrinkReduce volume sizeMedium
activeMark partition bootableMedium

Try Diskpart Concepts in Our Simulator

Want to understand disk management concepts without risking real data? Use our interactive Windows Command Simulator to safely explore command-line operations. While diskpart itself requires extreme caution on real systems, our simulator provides a risk-free learning environment.

Explore our complete Windows Commands Reference for detailed documentation on 200+ CMD commands, including chkdsk, format, and other storage management tools essential for Windows system administration.

Summary

The diskpart command provides comprehensive command-line control over Windows storage, from basic partition creation and formatting to advanced operations like MBR/GPT conversion and RAID management. Whether preparing new disks, creating bootable USB media, extending volumes to reclaim space, or performing emergency recovery when GUI tools fail, diskpart delivers capabilities essential for advanced storage administration—but with significant risks requiring careful, deliberate operation.

Understanding diskpart's immediate, irreversible nature is critical: commands like clean permanently erase all data without confirmation or undo options. The wrong disk selection destroys Windows installations or personal data instantly. Essential safety practices include always verifying disk selection with list disk, documenting partition layouts before changes, maintaining current backups, and testing operations on disposable media before production use.

Key operational principles include entering interactive mode for safety (prevents accidental one-line disasters), selecting correct disks with meticulous verification, understanding MBR versus GPT implications, recognizing shrink limitations from unmovable files, and using scripts for repeatable operations. For production environments, consider safer alternatives like PowerShell's disk cmdlets or GUI Disk Management unless diskpart's specific capabilities are required.

Most importantly, diskpart excels in scenarios where GUI tools are unavailable or insufficient: emergency recovery from boot failures, scripted enterprise disk provisioning, operations blocked by corrupted Disk Management databases, and low-level troubleshooting requiring direct partition table manipulation. Master diskpart commands, respect its destructive potential, and incorporate rigorous verification procedures into workflows to harness its power while avoiding catastrophic data loss from selection errors or hasty execution.

Practice diskpart exclusively on disposable USB drives or virtual machines until thoroughly comfortable with commands, always maintain backup strategies independent of diskpart operations, and document every major storage operation for troubleshooting and recovery purposes.