diskpart
Microsoft’s command-line disk partitioning utility for Windows. Introduced in Windows 2000/XP as a replacement for fdisk, diskpart remains current through Windows 11 and Windows Server 2025. Operates as an interactive shell at the DISKPART> prompt rather than as a single-shot command. Uses a focus model: list objects (list disk, list partition, list volume), then select one (select disk N) before issuing operational commands. Common operations include partition creation, deletion, formatting, drive letter assignment, MBR/GPT conversion, and disk cleaning. The clean command removes partition tables; clean all zeroes every sector for secure erasure. Available in Windows Recovery Environment and supports scripting via /s parameter. Destructive by design: no undo capability.
EaseUS · MiniTool · Seagate
list/select focus model
Windows 2000 origin
diskpart is Microsoft’s built-in command-line disk partitioning utility for Windows. Introduced in Windows 2000/XP as a replacement for fdisk, it operates as an interactive shell at the DISKPART> prompt with a focus model: list objects, then select one before issuing commands. Common operations include partition creation, deletion, formatting, drive letter assignment, and conversion between MBR and GPT partition styles. The clean command removes partition metadata; clean all zeroes every sector. Unlike file-system check tools like chkdsk, diskpart operates at the partition table level. Destructive by design: no undo capability for any command.
What diskpart Is
The Microsoft Learn diskpart reference provides the canonical definition: “The diskpart command interpreter helps you manage your computer’s drives (disks, partitions, volumes, or virtual hard disks). Before you can use diskpart commands, you must first list, and then select an object to give it focus. After an object has focus, any diskpart commands that you type will act on that object.”1
The Windows 2000 origin
diskpart was introduced as part of Windows 2000 and Windows XP, replacing the legacy fdisk utility from MS-DOS and earlier Windows versions. The progression:
- MS-DOS / Windows 9x: fdisk was the partition management tool; menu-driven, limited capabilities.
- Windows 2000: diskpart introduced for both server administration and Recovery Console use.
- Windows XP: diskpart standardized as the primary partition tool; Recovery Console version had different command set.
- Windows Vista (2007): diskpart enhanced with VHD support and additional commands.
- Windows 7: dynamic disk and SSD-aware features added.
- Windows 8 (2012): PowerShell Storage cmdlets (Get-Disk, New-Partition, etc.) introduced as modern alternative.
- Windows 10/11/Server 2025: diskpart continues unchanged in core functionality; PowerShell preferred for scripting.
The interactive shell model
The Computer Hope diskpart reference describes the launch behavior: “To start DiskPart, run the diskpart command, from the Run box or a Command Prompt… You are presented with the DISKPART> prompt, where DiskPart commands are entered and run.”2 Key shell behaviors:
- Typing
diskpartin a regular Command Prompt opens the diskpart shell in the same window. - The DISKPART> prompt indicates you’re in the interactive shell; regular CMD commands won’t work here.
- The shell displays the diskpart version and computer name on launch.
- Type
exitto leave the diskpart shell and return to regular CMD. - Each diskpart session maintains its own focus state independent of other sessions.
- Closing the window without typing exit terminates diskpart immediately.
The focus model
The focus model is fundamental to diskpart usage. The Microsoft Learn reference describes the behavior: “When you select an object, the focus remains on that object until you select a different object. For example, if the focus is set on disk 0 and you select volume 8 on disk 2, the focus shifts from disk 0 to disk 2, volume 8. Some commands automatically change the focus. For example, when you create a new partition, the focus automatically switches to the new partition.” The asterisk (*) indicator:
- After running list disk, list partition, or list volume, an asterisk appears next to the focused object.
- Without focus, operational commands like delete, format, assign produce errors.
- Different object types have separate focus: a disk can be focused independently from a partition.
- Selecting a partition automatically focuses its parent disk.
- Selecting a volume may shift focus across disks if the volume spans them.
Privileges and execution requirements
diskpart has specific requirements:
- Administrator privileges required: the user must be in the local Administrators group.
- UAC prompt on Windows 10/11: non-administrators see a UAC prompt; answering Yes elevates the session.
- “Run as administrator” for Command Prompt: launching CMD with admin rights is the standard approach.
- Cannot operate on the boot disk for clean: “Clean is not allowed on the boot disk” error prevents accidental destruction.
- Available in Windows Recovery Environment (WinRE): when Windows won’t boot, diskpart is accessible via recovery boot.
- Available in Windows Preinstallation Environment (WinPE): deployment scenarios use diskpart for disk preparation.
Comparison with related tools
| Tool | Type | Scope | Modern role |
|---|---|---|---|
| diskpart | Command-line interactive shell | Disks, partitions, volumes, VHDs | Standard Windows partition tool |
| Disk Management (diskmgmt.msc) | GUI utility | Same as diskpart | Visual front-end for diskpart operations |
| PowerShell Storage cmdlets | PowerShell module | Same as diskpart | Modern scripting alternative (Win 8+) |
| fdisk (legacy) | Command-line | MBR partitioning only | Replaced by diskpart in Windows 2000 |
| format.exe | Command-line | File system format only | Subset of diskpart’s format command |
| mbr2gpt.exe | Command-line | MBR-to-GPT conversion | Non-destructive alternative to diskpart convert |
The diskpart Command Set
diskpart supports approximately 38 commands organized around object types and operations. Understanding the command set clarifies what diskpart can and cannot do for partition management.
The list and select pair
The list/select pattern is the foundation of diskpart usage:
- list disk: displays all physical disks with size, status, free space, dynamic flag, GPT flag.
- list partition: displays partitions on the focused disk with type, size, offset.
- list volume: displays all volumes (mounted partitions) with drive letter, label, file system, type, size, status.
- list vdisk: displays virtual hard disks (VHDs).
- select disk N: focuses disk number N (where N is from list disk output).
- select partition N: focuses partition number N on the focused disk.
- select volume N: focuses volume number N (or letter, e.g., select volume D).
- select vdisk file=path: focuses a virtual hard disk by file path.
Partition creation and deletion
Creation and deletion commands operate on the focused disk:
- create partition primary [size=N]: creates a primary partition; size in MB; without size, uses all available space.
- create partition extended: creates an extended container for logical partitions (MBR only).
- create partition logical [size=N]: creates a logical partition inside the extended container.
- create partition efi: creates an EFI System Partition (ESP) on GPT disks.
- create partition msr [size=N]: creates a Microsoft Reserved partition on GPT disks.
- delete partition: deletes the focused partition; cannot delete system or boot partitions without override.
- delete partition override: forces deletion of system partitions; rarely needed and dangerous.
Format and drive letter assignment
Once a partition exists, format and assign are typical next steps:
- format fs=ntfs quick: NTFS quick format (no full surface scan); typical for internal drives.
- format fs=fat32 quick: FAT32 quick format; typical for USB drives and bootable media.
- format fs=exfat quick: exFAT quick format; typical for large USB drives and SD cards.
- format fs=ntfs label=”My Drive” quick: includes volume label.
- format fs=ntfs: full format; performs surface scan; takes hours on large drives.
- assign letter=X: assigns drive letter X to the focused volume; X must be unused.
- assign mount=path: mounts the volume at a specified NTFS folder path instead of a drive letter.
- remove letter=X: removes drive letter assignment.
Disk-level commands
Several commands operate on the focused disk rather than partitions:
- active: marks the focused partition as active (bootable) on MBR disks.
- online disk: brings an offline disk online; required for disks marked offline.
- offline disk: takes a disk offline; useful for hardware operations.
- convert mbr / convert gpt: converts the focused disk between partition styles (destructive).
- convert basic / convert dynamic: converts between basic and dynamic disk types (destructive in some cases).
- attributes disk set readonly / clear readonly: sets or clears the disk-level read-only flag.
- uniqueid disk: displays or sets the disk’s unique GUID (GPT) or signature (MBR).
- rescan: re-enumerates hardware; useful after connecting/disconnecting drives.
Volume and partition attributes
The attributes command modifies hidden flags that affect visibility:
- attributes volume set hidden: hides the volume from File Explorer.
- attributes volume clear hidden: unhides the volume.
- attributes volume set readonly: makes the volume read-only.
- attributes volume clear readonly: removes read-only flag (useful for stuck drives).
- attributes volume set nodefaultdriveletter: prevents automatic drive letter assignment.
- gpt attributes=N: sets GPT-specific partition attributes (system, hidden, no automount).
Detail and information commands
Several commands provide detailed information about focused objects:
- detail disk: shows detailed info about the focused disk (model, serial, type, status, paths).
- detail partition: shows partition details (type, hidden, active, offset, size).
- detail volume: shows volume details (label, file system, type, size, drive letter, hidden, read-only).
- filesystems: lists supported file systems for the current volume.
- help command: shows help for a specific command.
Scripting with diskpart
The Microsoft Learn diskpart scripts reference describes scripting: “Use diskpart /s to run scripts that automate disk-related tasks, such as creating volumes or converting disks to dynamic disks. Scripting these tasks is useful if you deploy Windows by using unattended Setup or the Sysprep tool, which do not support creating volumes other than the boot volume.”3 Scripting characteristics:
- Scripts are plain text files; one diskpart command per line.
- Lines starting with
remare comments. - Run via
diskpart /s scriptname.txtfrom the Command Prompt. - By default, errors stop script execution; the
noerrparameter on individual commands continues despite errors. - Consecutive scripts require 15-second pause:
timeout /t 15between batch invocations. - Sample script for ESP creation:
select disk 0 / clean / convert gpt / create partition primary size=300 / format quick fs=ntfs label=Windows RE tools / assign letter=T.
The clean and clean all Distinction
clean and clean all are diskpart’s two destructive disk-wiping commands. The distinction between them is critical for both repurposing and secure disposal scenarios.
What clean does
The MiniTool diskpart reference describes clean: “According to Microsoft, diskpart clean is a command that will remove any and all partitions or volumes from a disk. On master boot record (MBR) disks, only the MBR partitioning information and hidden sector information are overwritten. On GUID partition table (GPT) disks, the GPT partitioning information, including the Protective MBR, is overwritten; there is no hidden sector information. The disk state after cleaning is ‘Uninitialized’.”4 Specific behavior:
- On MBR disks: zeros the first 1 MB and the last 1 MB of the disk; the partition table and any hidden sector information is destroyed.
- On GPT disks: zeros the GPT header at start, the GPT backup at end, and the Protective MBR.
- User data on the disk remains physically intact; only the metadata describing partition layout is destroyed.
- Disk state after clean is “Uninitialized”; Disk Management shows it as raw, requiring re-initialization.
- Completes in seconds even on multi-TB drives.
What clean all does
The EaseUS diskpart reference describes clean all: “The ‘clean all’ command does the same thing as the clean command above, but it also specifies that each sector on the drive is zeroed (secure erase), erasing all data on the disc completely. The data on the disc will be unrecoverable as a result of this. Running the ‘clean all’ command on a drive will take roughly an hour for 320 GB.”5 Specific behavior:
- Zeros every sector on the disk from beginning to end.
- Time scales linearly with disk size: ~1 hour per 320 GB on HDDs; faster on SSDs.
- Cannot be interrupted safely; partial clean all leaves the disk in an inconsistent state.
- Recovery is generally impossible: every sector contains zeros; no metadata or content remains.
- Equivalent to a basic Secure Erase but without the firmware-level optimizations of Secure Erase.
- Single-pass zero wipe; not multi-pass like DoD 5220.22-M wiping.
When to use which
| Scenario | Recommended | Reason |
|---|---|---|
| USB drive won’t format | clean | Fast partition table reset |
| Convert MBR to GPT | clean | Required prerequisite |
| Drive shows wrong capacity | clean | Resets partition table to native size |
| Repurpose drive for new OS | clean | Quick metadata removal |
| Sell or give away drive | clean all | Removes user data securely |
| Dispose of drive (HIPAA/PCI) | Secure Erase or DBAN, not clean all | Compliance requires verified destruction |
| Bootable USB creation | clean | Sufficient for new bootable media |
| Suspected malware in MBR | clean | Removes infected boot code |
The recovery prospects
The recovery distinction is sharp:
- After clean: data is recoverable using partition recovery tools (TestDisk, MiniTool Partition Wizard, EaseUS Partition Recovery, R-Studio); files survive intact, only the partition table is gone.
- After clean all: data is generally unrecoverable; every sector contains zeros; even forensic services cannot reconstruct content.
- The MiniTool reference notes the distinction: “Another similar command is named ‘clean all’, which will specify that each and every sector on the disk is zeroed, and completely deletes all data contained on the disk. In this case, even data recovery software cannot help.”
The boot disk protection
The MiniTool reference describes a critical safety feature: “Wrong diskpart clean won’t happen on the system disk we are boot from, for once we type the clean command and press Enter key, we will receive the following error message: Virtual Disk Service error: Clean is not allowed on the boot disk.” This prevents accidental destruction of the running Windows installation. However:
- The protection only applies to the currently-running boot disk.
- If running from WinRE, WinPE, or installation media, the protection doesn’t apply to the normally-booted system disk.
- External boot environments allow clean to operate on any internal disk.
- This is why “I cleaned the wrong disk” scenarios typically happen during recovery operations rather than normal Windows use.
MBR/GPT Conversion and Partition Style Management
diskpart’s MBR-to-GPT and GPT-to-MBR conversion is a destructive operation that requires the disk to be cleaned first. This is one of diskpart’s most-used recovery scenarios but also one of its most-misunderstood capabilities.
The conversion sequence
The Microsoft Learn convert disk reference describes the standard sequence: “(1) Open an elevated command prompt window, type diskpart, then hit Enter; (2) Type list disk and hit Enter, make a note of the disk number that you want to convert; (3) Type select disk, provide the disk number you want to convert, then hit Enter; (4) Type clean to delete all partitions and volumes on the disk; (5) To convert GPT to MBR, type convert mbr, then hit Enter. To convert MBR to GPT, type convert gpt, then hit Enter.”6
Why clean is required
diskpart cannot convert a disk that contains partitions; the clean step is mandatory:
- diskpart’s convert command requires an empty (uninitialized) disk.
- Existing partitions must be deleted first; the simplest way is via clean.
- Individual delete partition commands work but require selecting and deleting each partition.
- The destructive nature is fundamental: there’s no way to convert with diskpart without losing all data.
- Microsoft’s separate
mbr2gpt.exetool (Windows 10+) provides non-destructive MBR-to-GPT conversion for system disks specifically.
MBR vs GPT decision factors
The Microsoft Learn convert disk reference summarizes the partition style differences: “Master Boot Record (MBR) disks use the legacy BIOS partitioning scheme (also known as partition style) and supports up to four primary partitions per disk. MBR is limited to disks of 2 TB or smaller and isn’t recommended for larger drives. GUID Partition Table (GPT) disks use the modern Unified Extensible Firmware Interface (UEFI), supports more than four partitions, and can manage disks larger than 2 TB.” When to use each:
| Factor | MBR | GPT |
|---|---|---|
| Maximum disk size | 2 TB | Effectively unlimited (9.4 ZB theoretical) |
| Maximum primary partitions | 4 (or 3 + extended container) | 128 by default |
| Boot firmware | Legacy BIOS | UEFI (required for Windows 8+) |
| Backup partition table | None | Yes (at end of disk) |
| Checksums for integrity | No | Yes (CRC32) |
| Cross-platform compatibility | Universal (legacy) | Universal (modern) |
| Bootable Windows version | Windows XP+ (32-bit and 64-bit) | Windows 7+ (64-bit only) |
Common conversion scenarios
Several specific scenarios drive MBR/GPT conversions:
- “Windows cannot be installed on this disk” (MBR error): Windows installer detected UEFI mode but disk is MBR; convert to GPT.
- “Windows cannot be installed on this disk” (GPT error): Windows installer detected legacy BIOS mode but disk is GPT; convert to MBR.
- 3TB+ drive showing as 2TB: MBR limitation; convert to GPT to access full capacity.
- USB drive bootable in only one mode: may need MBR for legacy BIOS, GPT for UEFI; or MBR with active flag for universal compatibility.
- Need more than 4 partitions: MBR is limited; convert to GPT for unlimited partitions.
- Migrating from older to newer system: typical path is MBR-to-GPT for UEFI Windows 11 compatibility.
The dynamic vs basic disk distinction
diskpart also handles dynamic-to-basic conversion. Dynamic disks are a Windows-only feature for software RAID, spanning, and complex volumes:
- convert dynamic: converts a basic disk to dynamic; mostly preserves data but with caveats.
- convert basic: converts a dynamic disk to basic; requires deleting all dynamic volumes first.
- Modern recommendation: avoid dynamic disks; use Storage Spaces (Win 8+) for software RAID instead.
- Microsoft considers dynamic disks legacy: still supported but no new development.
- Recovery implications: dynamic disk metadata can be more complex to recover than basic disk partition tables.
Common bootable USB workflow
One of the most common diskpart workflows is creating a bootable USB drive:
- Open Command Prompt as Administrator.
- Type
diskpartto enter the shell. - Type
list diskto see all disks. - Identify the USB drive by size; type
select disk N. - Type
cleanto remove existing partition data. - Type
create partition primaryto create a primary partition. - Type
select partition 1. - Type
activeto mark partition as bootable (MBR only). - Type
format fs=fat32 quickfor FAT32 (UEFI compatible) orformat fs=ntfs quickfor NTFS. - Type
assign letter=Xto assign a drive letter. - Type
exitto leave diskpart. - Copy bootable image files to the USB drive.
diskpart and Data Recovery
diskpart’s role in data recovery is dual: it’s both a recovery tool (for partition repair scenarios) and a destruction tool (clean and clean all destroy data). Understanding which applies in any situation is essential for successful recovery.
When diskpart helps recovery
diskpart can be a recovery enabler in several specific scenarios:
- USB drive showing wrong capacity: clean restores access to full capacity.
- Drive stuck in read-only state: attributes disk clear readonly removes the flag.
- Drive showing as RAW or unknown: investigation via list disk and detail disk identifies the issue.
- Hidden recovery partitions blocking reformat: delete partition override removes them.
- Partition style mismatch preventing OS install: convert to appropriate style.
- Bootable USB creation for recovery: standard workflow described above.
- Removing leftover system reserved partitions: from previous Windows installs.
- Repairing dynamic disk issues: convert basic to remove problematic dynamic configurations.
When diskpart destroys data
The destructive scenarios are equally important to understand:
- clean on the wrong disk: the most common diskpart disaster; identifying disk by size only is risky.
- clean all on any disk: renders data unrecoverable; not undoable even by professionals.
- delete partition without backup: partition recovery may work but isn’t guaranteed.
- convert mbr/gpt: requires clean; data on the disk is destroyed.
- format fs=ntfs (full format): writes zero pattern across the volume; destroys data.
- delete partition override on system partitions: can render Windows unbootable.
The clean recovery scenario
When diskpart clean has been run on the wrong disk, recovery is possible but time-sensitive:
- Stop using the affected disk immediately: any writes can overwrite recoverable data.
- Image the disk first: use ddrescue or similar to create a sector-level disk image; preserves the post-clean state for multiple recovery attempts.
- Use partition recovery software: TestDisk (free), MiniTool Partition Wizard, EaseUS Partition Recovery, R-Studio, AOMEI Partition Assistant scan for orphaned partition signatures.
- Reconstruct the partition table: recovery tools rebuild the MBR or GPT based on detected partition boundaries.
- Verify file system access: after partition recovery, file systems should be readable normally.
- Copy data off the recovered drive: save to a separate destination; don’t trust the recovered partition long-term.
- Reformat properly: after data is safe, reformat the drive for normal use.
The clean all consequence
clean all is essentially irreversible:
- Every sector contains zeros; there are no recovery signatures to find.
- File system metadata, partition tables, file content: all gone.
- Even cleanroom recovery services cannot recover from properly zeroed disks.
- Hardware-level forensics (e.g., MFM/AFM analysis) on properly zeroed magnetic media has been shown ineffective on modern drives.
- Backup restoration is the only recovery option.
- The lesson: never run clean all without backup verification first.
Best practices for safe diskpart use
To minimize the risk of diskpart-caused data loss:
- Disconnect unrelated drives: reduce the chance of selecting the wrong disk.
- Verify disk identity by multiple criteria: size, model (via detail disk), drive letter (via list volume).
- Backup before any operation: diskpart has no undo.
- Use list before select, detail before action: confirm focus before destructive commands.
- Avoid clean all without explicit destruction need: clean is sufficient for repurposing.
- Test scripts on non-critical disks first: scripted diskpart can destroy data faster than interactive use.
- Document operations: record commands for troubleshooting and audit purposes.
Modern alternatives via PowerShell
Windows 8 introduced PowerShell Storage cmdlets that provide a more modern interface to the same operations:
- Get-Disk: equivalent to list disk.
- Get-Partition: equivalent to list partition.
- Get-Volume: equivalent to list volume.
- Clear-Disk: equivalent to clean.
- New-Partition: equivalent to create partition.
- Format-Volume: equivalent to format.
- Set-Partition: equivalent to active and various attributes commands.
- Advantages: object-oriented output, scriptable with PowerShell flow control, better integration with system administration scripts.
- Disadvantages: not available in WinRE/WinPE by default; diskpart remains the standard for recovery scenarios.
diskpart is the standard tool for partition-level operations on Windows: creating partitions, removing partitions, converting between MBR and GPT, fixing USB drives that won’t format, and managing virtual disks. For data recovery purposes, the practical implication is that diskpart sits at the partition table level above the file system, which means clean and clean all destroy partition information without modifying file content directly; the lost partition table makes data inaccessible until recovered. clean is recoverable; clean all is not. Understanding which scenarios call for diskpart (and which scenarios should never involve it) is fundamental to Windows storage administration.
For users wondering whether to use diskpart, the practical guidance follows the operation type. For routine partitioning of fresh drives, diskpart is appropriate and safe. For drives showing symptoms (won’t format, wrong capacity, RAW state) but with replaceable data, the clean → create → format workflow is the standard repair. For drives with irreplaceable data and any signs of issues, diskpart should be avoided entirely; image the drive first, then use partition recovery tools (TestDisk is free and excellent) to investigate. The Disk Management GUI counterpart accomplishes most diskpart operations more safely because it requires explicit click confirmations, but lacks some of diskpart’s capabilities; PowerShell Storage cmdlets are the modern scripting alternative for new automation.
For users facing diskpart-related recovery scenarios, the practical guidance reflects which command was run. After diskpart clean on the wrong disk, immediate action is critical: stop all writes, image the drive with ddrescue, and run TestDisk or MiniTool Partition Wizard against the image to reconstruct the partition table. Standard data recovery software often includes partition recovery features; HDD-focused recovery tools apply to drives that experienced clean rather than clean all. After diskpart clean all, recovery from backup is the only option; the disk now contains only zeros. The strongest defense remains preventive: comprehensive backups before any diskpart operation, careful disk identification before clean commands, and never running clean all unless secure data destruction is the explicit goal. Cleanroom recovery services can address physical drive damage but cannot reverse zeroed sectors; clean all bypasses physical recovery entirely.
diskpart FAQ
diskpart is Microsoft’s built-in command-line disk partitioning utility for Windows. The Microsoft Learn diskpart reference describes its purpose: it is a command interpreter that helps users manage computer drives including disks, partitions, volumes, and virtual hard disks (VHDs). Introduced in Windows 2000/XP as a replacement for the legacy fdisk utility, diskpart remains the canonical Windows partition management tool through Windows 11, Windows Server 2025, and the Windows Recovery Environment. Unlike single-shot commands, diskpart operates as an interactive shell: typing ‘diskpart’ opens a DISKPART> prompt where subsequent commands are entered. Common operations include creating and deleting partitions, formatting volumes, assigning drive letters, converting partition styles between MBR and GPT, cleaning disks, marking partitions active, and managing dynamic vs basic disks. diskpart supports scripting via the /s parameter for automation. The tool requires Administrator privileges and is destructive by design: nearly every command modifies disk structures with no undo capability.
diskpart uses a focus model where commands operate on whichever object (disk, partition, or volume) currently has focus. The Microsoft Learn diskpart reference describes the pattern: “Before you can use diskpart commands, you must first list, and then select an object to give it focus. After an object has focus, any diskpart commands that you type will act on that object. When you select an object, the focus remains on that object until you select a different object. For example, if the focus is set on disk 0 and you select volume 8 on disk 2, the focus shifts from disk 0 to disk 2, volume 8.” The standard workflow: (1) Run ‘list disk’ to see all disks; (2) Run ‘select disk N’ to focus a specific disk; (3) Run ‘list partition’ to see partitions on the focused disk; (4) Run ‘select partition N’ to focus a specific partition; (5) Run operational commands like ‘format’, ‘delete’, ‘assign letter’. After running list, an asterisk (*) appears next to the object currently in focus. Some commands automatically change focus: when you create a new partition, the focus automatically switches to the new partition.
clean and clean all are two different destructive commands with very different speed and security characteristics. The MiniTool diskpart reference describes clean: “According to Microsoft, diskpart clean is a command that will remove any and all partitions or volumes from a disk. On master boot record (MBR) disks, only the MBR partitioning information and hidden sector information are overwritten. On GUID partition table (GPT) disks, the GPT partitioning information, including the Protective MBR, is overwritten; there is no hidden sector information.” The EaseUS reference describes clean all: “The clean all command does the same thing as the clean command above, but it also specifies that each sector on the drive is zeroed (secure erase), erasing all data on the disc completely. The data on the disc will be unrecoverable as a result of this. Running the clean all command on a drive will take roughly an hour for 320 GB.” Practical implications: clean is fast (seconds) and destructive only of partition metadata; data on the disk remains intact and recoverable with partition recovery software. clean all is slow (hours) and zeroes every sector, making the data unrecoverable even with professional recovery tools. clean all is appropriate for secure disposal; clean is appropriate for repurposing drives where data recovery is acceptable.
Converting between MBR and GPT with diskpart is destructive: the disk must be cleaned first because diskpart cannot convert disks containing partitions. The Microsoft Learn convert disk reference describes the procedure: “(1) Open an elevated command prompt window, type diskpart, then hit Enter; (2) Type list disk and hit Enter, make a note of the disk number that you want to convert; (3) Type select disk, provide the disk number you want to convert, then hit Enter; (4) Type clean to delete all partitions and volumes on the disk; (5) To convert GPT to MBR, type convert mbr, then hit Enter. To convert MBR to GPT, type convert gpt, then hit Enter.” The clean step destroys all data on the disk; back up first or use Microsoft’s separate mbr2gpt.exe utility (available in Windows 10+) for non-destructive conversion of system disks. After conversion: the disk has no partitions and must be partitioned again with create partition primary, formatted with format fs=ntfs quick, and assigned a drive letter with assign letter=X. Common reason for conversion: MBR limits disks to 2TB and 4 primary partitions; GPT supports drives over 2TB and unlimited partitions; UEFI boot requires GPT for system disks.
diskpart is the standard tool for fixing USB drives that won’t format through normal methods. The typical recovery workflow: (1) Open Command Prompt as Administrator and type ‘diskpart’ to enter the interactive shell; (2) Type ‘list disk’ to see all connected disks; (3) Identify the USB drive by size (be very careful: selecting the wrong disk will destroy data); (4) Type ‘select disk N’ where N is the USB drive number; (5) Type ‘clean’ to remove all partition information; (6) Type ‘create partition primary’ to create a single primary partition spanning the drive; (7) Type ‘format fs=fat32 quick’ for FAT32 (or fs=ntfs quick for NTFS, fs=exfat quick for exFAT); (8) Type ‘assign letter=X’ where X is an unused drive letter; (9) Type ‘exit’ to leave diskpart. This sequence resolves the most common USB issues including drive showing wrong capacity, partition table corruption, write-protect flags from previous bootable USB use, and leftover system reserved partitions from Windows installation media. The same sequence works for SD cards, external HDDs, and other removable storage. For drives that report read-only, run ‘attributes disk clear readonly’ after select disk before clean.
Yes for clean, no for clean all. After diskpart clean, the data on the disk remains physically intact; only the partition table metadata has been overwritten. The MiniTool diskpart reference describes the recovery prospects: “Note: Once diskpart clean is carried out, please stop making any changes to the hard drive to ensure the possibility of data recovery to the largest extent.” Recovery process: (1) Stop using the affected disk immediately to prevent overwrites; (2) Use partition recovery software (TestDisk, MiniTool Partition Wizard, EaseUS Partition Recovery, R-Studio) which scan the disk for orphaned partition signatures and reconstruct the partition table; (3) After successful partition recovery, file system metadata becomes accessible and files can be read normally. After diskpart clean all, recovery is generally impossible because every sector has been zeroed; even professional recovery services cannot recover data from properly zeroed sectors. The standard rule for recovery from diskpart clean: image the disk first with ddrescue or similar, then run partition recovery against the image to preserve the original state if multiple recovery attempts are needed. For drives where clean all has been run, only restoration from backup remains as a recovery option.
Related glossary entries
- chkdsk: Windows file system check tool; complements diskpart at the file-system level.
- MBR: legacy partition style; diskpart manages MBR disks via convert mbr.
- GPT: modern partition style; diskpart manages GPT disks via convert gpt.
- Partition: the primary object diskpart operates on; create, delete, format, assign.
- Secure Erase: vendor-level alternative to diskpart clean all for sanitization.
- Disk Image: the recommended pre-diskpart step for data recovery scenarios.
- Data Corruption: partition-level corruption is one diskpart use case.
Sources
- Microsoft Learn: diskpart command reference (accessed May 2026)
- Computer Hope: DiskPart Command
- Microsoft Learn: diskpart scripts and examples
- MiniTool: Undo Diskpart Clean Command
- EaseUS: What Is DiskPart Clean and How to Use It
- Microsoft Learn: Convert a disk to GPT or MBR
- Wikipedia: diskpart Wikipedia entry
- CommandWindows: Managing Microsoft Windows disks with the command Diskpart
- Windows Central: Use DiskPart to clean and format a drive
About the Authors
Data Recovery Fix earns revenue through affiliate links on some product recommendations. This does not influence our reference content. Glossary entries are written and reviewed independently based on documented research, vendor documentation, independent testing, and recovery-engineer review. If anything on this page looks inaccurate, outdated, or worth revisiting, please reach out at contact@datarecoveryfix.com and we’ll review it promptly.
