Verified June 2026 · tested on Windows 11 24H2, Windows 10 22H2 & Server 2022/2025
Warning — read this first.
cleanandclean allerase the entire selected disk, and selecting the wrong disk number means wiping the wrong drive. diskpart does not ask "are you sure?" Always runlist disk, identify your target by size, thenselect disk Nand confirm before any destructive command. Back up first.
Quick Reference: Essential Commands
Need to prep a blank disk right now? Here is the canonical "wipe, partition, format, assign" sequence:
diskpart :: launch the interactive utility (elevated)
list disk :: show every physical disk — note the SIZE
select disk 2 :: target disk 2 (verify the size first!)
clean :: ERASES the selected disk's partition table
create partition primary :: create one primary partition spanning the disk
select partition 1 :: select the partition you just made
format fs=ntfs quick :: quick-format it as NTFS
assign letter=E :: give it drive letter E:
exit :: leave diskpart
Which command do you need?
- See what disks/volumes/partitions exist →
listcommands - Choose what to operate on →
select disk/select partition - Wipe a disk completely →
clean/clean all - Create and format a partition →
create partition+format - Assign a drive letter →
assign - Mark a partition bootable →
active - Switch partition style →
convert gpt/convert mbr - Online/offline & read-only →
online disk/attributes
diskpart is interactive: you launch diskpart, then type one command per line. Almost every command operates on whatever object is currently selected, so selection mistakes are the #1 cause of data loss.
list: Inventory Disks, Volumes, and Partitions
The three list commands are how you see what you have before touching anything. Run list disk every single time before a destructive command.
Windows 10Windows 11Server 2016+Built in — no moduleNon-destructive
list Command Reference
| Command | Shows |
|---|---|
list disk | Every physical disk: number, status, total size, free space, and * under Gpt for GPT disks |
list volume | Every volume (formatted partitions) with drive letter, label, filesystem, and size |
list partition | Partitions on the currently selected disk (run select disk first) |
list Usage Examples
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 476 GB 0 B *
Disk 1 Online 1863 GB 0 B *
Disk 2 Online 14 GB 14 GB
DISKPART> select disk 2
DISKPART> list partition
DISKPART> list volume
Note: In the example above, Disk 2 is a 14 GB USB stick and Disk 0 is the 476 GB Windows system disk. The size column is your safety check — never trust the disk number alone, because numbers can change when drives are added or after a reboot.
select: Choose the Target Object
select sets the object that subsequent commands act on. There is a separate selection context for disk, partition, and volume. Getting this wrong is how the wrong drive gets erased.
Windows 10Windows 11Server 2016+⚠ Selection drives every destructive command
select Command Reference
| Command | Effect |
|---|---|
select disk N | Make physical disk N the current disk |
select partition N | Make partition N (on the current disk) the current partition |
select volume N | Make volume N the current volume (can also use a drive letter: select volume E) |
detail disk | Show model, serial, and partitions of the selected disk — use it to confirm identity |
detail partition / detail volume | Show details of the selected partition/volume |
select Usage Examples
:: Always confirm BEFORE doing anything destructive
DISKPART> list disk
DISKPART> select disk 2
DISKPART> detail disk :: verify model + serial match the drive you intend to wipe
:: Select a volume by its drive letter instead of number
DISKPART> select volume E
Warning: After
select disk N, every laterclean,create,format, orconvertcommand hits that disk with no further confirmation. If you are unsure which disk is selected, runlist diskagain — the selected object is marked with an asterisk (*) in the leftmost column.
clean: Erase the Entire Disk
clean removes all partition, volume, and formatting information from the currently selected disk. This is the destructive heart of diskpart.
Windows 10Windows 11Server 2016+⚠ DESTROYS ALL DATA on the disk
clean Command Reference
| Command | Effect | Speed |
|---|---|---|
clean | Deletes the partition table and metadata sectors. File data remains on the platters until overwritten, but all partitions become inaccessible | Seconds |
clean all | Zeros every sector on the disk — a secure wipe that makes data unrecoverable | Minutes to hours depending on capacity |
clean Usage Examples
:: Repurpose a disk quickly (data theoretically recoverable until overwritten)
DISKPART> list disk
DISKPART> select disk 2
DISKPART> clean
:: Securely wipe a disk before disposal/resale (zeros the whole drive)
DISKPART> select disk 2
DISKPART> clean all
Warning:
cleanandclean allerase the entire selected disk — not a single partition. There is no undo and no confirmation prompt. Selecting the wrong disk number wipes the wrong drive. Before running either, runlist disk, confirm the size matches your target, and rundetail diskto check the model/serial. Make sure you have a backup.
Warning: Never run
cleanagainstDisk 0on a normal PC — that is almost always the disk Windows is running from. diskpart will refuse to clean a disk holding the running OS, but on a multi-disk or WinPE/Setup environment that protection may not apply.
create partition: Carve Out Space
After clean, the disk is empty. create partition allocates space; format makes it usable.
Windows 10Windows 11Server 2016+Built in — no module
create partition / format Reference
| Command | Effect |
|---|---|
create partition primary | Create a primary partition using all remaining space (or add size=N for N megabytes) |
create partition primary size=51200 | Create a 50 GB primary partition (size is in MB) |
create partition extended / create partition logical | MBR-only: extended container and logical drives inside it |
create partition efi size=100 | GPT system disks: 100 MB EFI System Partition |
create partition msr size=16 | GPT system disks: Microsoft Reserved partition |
format fs=ntfs quick | Quick-format the selected partition as NTFS |
format fs=fat32 quick label="DATA" | Quick-format as FAT32 with a volume label |
format fs=exfat quick | Quick-format as exFAT (good for large cross-platform removable media) |
create + format Usage Examples
:: One partition spanning the whole disk, NTFS, drive letter E:
DISKPART> select disk 2
DISKPART> create partition primary
DISKPART> select partition 1
DISKPART> format fs=ntfs quick label="Backup"
DISKPART> assign letter=E
:: A 50 GB partition, then the rest as a second partition
DISKPART> create partition primary size=51200
DISKPART> create partition primary
Note: Use
quickfor everyday formatting — it writes a fresh filesystem in seconds. Omittingquickperforms a full format that also scans the entire surface for bad sectors, which can take a long time on large disks. A full format does not securely erase data the wayclean alldoes.
assign: Give the Volume a Drive Letter
assign mounts the selected volume at a drive letter so Windows can use it. remove unmounts it.
Windows 10Windows 11Server 2016+Non-destructive
assign Command Reference
| Command | Effect |
|---|---|
assign | Assign the next available drive letter automatically |
assign letter=E | Assign a specific drive letter (E:) |
assign mount=C:\Mount\Data | Mount the volume at an empty NTFS folder instead of a letter |
remove letter=E | Remove the E: drive letter (volume stays intact, just hidden) |
assign Usage Examples
DISKPART> select volume 3
DISKPART> assign letter=E
:: Hide a recovery/system volume by removing its letter
DISKPART> select volume 3
DISKPART> remove letter=E
Note:
assignandremoveonly change how a volume is mounted — they do not erase data. Removing a letter is a safe way to hide a volume from users without deleting it.
active: Mark the Boot Partition (MBR only)
active flags the selected primary partition as the one the BIOS firmware boots from. It applies only to MBR disks.
MBR disks onlyLegacy BIOS boot⚠ Wrong partition = unbootable
active Command Reference
| Command | Effect |
|---|---|
active | Mark the selected partition active (the system/boot partition) |
inactive | Clear the active flag from the selected partition |
active Usage Examples
:: Make partition 1 bootable on a legacy-BIOS MBR disk
DISKPART> select disk 1
DISKPART> select partition 1
DISKPART> active
Warning:
activeonly matters on MBR disks booting via legacy BIOS. GPT/UEFI systems ignore the active flag and boot from the EFI System Partition instead. Marking the wrong partition active — or setting it on a data disk — can leave Windows unable to boot. Only mark the partition that actually holds the boot files.
convert: Switch Between GPT and MBR
convert gpt and convert mbr change the partition style of the selected disk. The disk must be empty (no partitions) first.
Windows 10Windows 11Server 2016+⚠ Disk must be empty — usually requires clean
convert Command Reference
| Command | Effect | Requirement |
|---|---|---|
convert gpt | Convert an empty disk to GUID Partition Table (needed for UEFI boot and disks > 2 TB) | No partitions on disk |
convert mbr | Convert an empty disk to Master Boot Record (legacy BIOS / compatibility) | No partitions on disk |
convert dynamic | Convert a basic disk to a dynamic disk | — |
convert basic | Convert an empty dynamic disk back to basic | No volumes on disk |
convert Usage Examples
:: Convert a disk to GPT (clean first, which erases it)
DISKPART> select disk 2
DISKPART> clean
DISKPART> convert gpt
:: Convert back to MBR
DISKPART> select disk 2
DISKPART> clean
DISKPART> convert mbr
Warning: Because
convert gpt/convert mbrrequire an empty disk, you almost always runcleanfirst — which erases the entire disk. To convert a Windows system disk from MBR to GPT without data loss, use Microsoft'sMBR2GPT.exetool instead, not diskpart.
online/offline and attributes: Disk State
These commands control whether a disk is accessible and whether it is read-only — useful for SAN volumes, signature collisions, and write-protected media.
Windows 10Windows 11Server 2016+Non-destructive
online/offline & attributes Reference
| Command | Effect |
|---|---|
online disk | Bring the selected disk online (accessible to Windows) |
offline disk | Take the selected disk offline (hidden from Windows) |
attributes disk | Show the current attributes of the selected disk (read-only state, etc.) |
attributes disk clear readonly | Clear the read-only flag so the disk can be written |
attributes disk set readonly | Make the disk read-only |
attributes volume clear readonly | Clear read-only on the selected volume |
online/offline Usage Examples
:: Bring an offline disk online and make it writable
DISKPART> list disk
DISKPART> select disk 3
DISKPART> online disk
DISKPART> attributes disk clear readonly
:: Take a disk offline
DISKPART> select disk 3
DISKPART> offline disk
Note: A disk that reports offline is often the result of the SAN policy (
Offline Sharedon Server) or a disk signature collision with another connected disk. Bringing it online or clearing read-only does not erase data — these are safe state changes.
Troubleshooting: diskpart Errors and Gotchas
Each row is deep-linkable — share a specific error with …#dp-virtdisk, and the row highlights on arrival.
| Message / Symptom | Meaning | Fix |
|---|---|---|
Access is denied | diskpart not running elevated | Launch Command Prompt/PowerShell as Administrator (Start-Process diskpart -Verb RunAs) |
Cannot clean a disk on which the current boot… | Trying to clean the running Windows disk | Boot from Windows Setup/WinPE and run diskpart from there |
The media is write protected | Disk or volume has the read-only attribute set | select disk N then attributes disk clear readonly |
Virtual Disk Service error: The disk is not empty | convert gpt/mbr on a disk that still has partitions | Run clean first (erases the disk), then convert |
The disk is offline because of policy | SAN policy or signature collision keeps the disk offline | select disk N, online disk, then attributes disk clear readonly |
There is no partition selected | Ran format/active without selecting a partition | list partition then select partition N first |
The arguments specified for this command are not valid | Wrong size= unit or value on create partition | Specify size in MB (e.g. size=51200 for 50 GB), or omit it for max |
Version-Specific & Compatibility Notes
- Windows 10 / 11 & Server:
diskpartis identical across modern versions and ships built in — no module or RSAT install required. Always run it from an elevated prompt. - GPT vs MBR: Use GPT for any disk over 2 TB and for UEFI boot disks; MBR only for legacy BIOS compatibility. The
activecommand applies to MBR disks only. - System disk conversion: To convert the Windows boot disk from MBR to GPT without erasing it, use
MBR2GPT.exe(Windows 10 1703+ and Windows 11), notdiskpart convert. - PowerShell alternative: The
Storagemodule (Get-Disk,Clear-Disk,New-Partition,Format-Volume,Set-Disk) does everything diskpart does and is scriptable. diskpart remains the fastest interactive option and is available in WinPE/Setup. - Scripting diskpart: Run a saved script non-interactively with
diskpart /s C:\scripts\prep.txt. Test scripts on a disposable disk first — there is no confirmation prompt for destructive commands. - Recovery reality: After
clean, partition-recovery tools (e.g. TestDisk) can sometimes rebuild the table if you stop writing to the disk immediately. Afterclean all, the disk is zeroed and data is unrecoverable. Treat every diskpart session as one keystroke away from data loss — back up first.






