DiskPart - Windows Disk Management
Master DiskPart, the powerful command-line disk partitioning utility built into Windows. Learn to manage disks, partitions, and volumes with precision.
Critical Warning: DiskPart commands can permanently destroy data. The CLEAN command erases ALL data on the selected disk. Always double-check disk numbers before executing commands.
How to Launch DiskPart
Method 1: Run Dialog (Recommended)
- Press Windows + R
- Type
diskpart
- Press Ctrl + Shift + Enter (for admin privileges)
- Click "Yes" on UAC prompt
Method 2: Command Prompt
- Open Command Prompt as Administrator
- Type
diskpart
and press Enter - Wait for DISKPART> prompt
- Begin entering commands
Note: DiskPart always requires administrator privileges to run.
Essential DiskPart Commands
Command | Description | Example | Risk Level |
---|---|---|---|
list disk | Display all physical disks | DISKPART> list disk | Safe |
list volume | Display all volumes | DISKPART> list volume | Safe |
list partition | Display partitions on selected disk | DISKPART> list partition | Safe |
select disk X | Select disk number X for operations | DISKPART> select disk 1 | Caution |
select volume X | Select volume number X | DISKPART> select volume 2 | Caution |
clean | Erase ALL data on selected disk | DISKPART> clean | Critical |
create partition primary | Create a primary partition | DISKPART> create partition primary size=10240 | Caution |
format fs=ntfs quick | Quick format with NTFS | DISKPART> format fs=ntfs quick label="Data" | Caution |
assign letter=X | Assign drive letter | DISKPART> assign letter=E | Low |
extend | Extend selected volume | DISKPART> extend size=5000 | Caution |
shrink | Shrink selected volume | DISKPART> shrink desired=1000 | Caution |
detail disk | Show detailed disk information | DISKPART> detail disk | Safe |
attributes | Display or set disk attributes | DISKPART> attributes disk | Low |
exit | Exit DiskPart utility | DISKPART> exit | Safe |
Common DiskPart Operations
DISKPART> list disk
DISKPART> select disk 1
DISKPART> clean # WARNING: Erases all data!
DISKPART> create partition primary
DISKPART> format fs=ntfs quick label="NewDrive"
DISKPART> assign letter=E
DISKPART> exit
This sequence completely erases the selected disk!
DISKPART> list disk
DISKPART> select disk 2
DISKPART> attributes disk clear readonly
DISKPART> online disk
DISKPART> convert gpt # Or 'convert mbr' for MBR
DISKPART> create partition primary
DISKPART> format fs=ntfs quick
DISKPART> assign letter=F
DISKPART> list volume
DISKPART> select volume 3
DISKPART> extend size=10240 # Extend by 10GB
# Or extend using all available space:
DISKPART> extend
Volume can only be extended if unallocated space exists immediately after it.
DISKPART> list disk
DISKPART> select disk 2 # Ensure this is your USB!
DISKPART> clean
DISKPART> create partition primary
DISKPART> select partition 1
DISKPART> active
DISKPART> format fs=fat32 quick
DISKPART> assign
DISKPART> exit
Triple-check the disk number - this will erase everything!
# To remove a drive letter:
DISKPART> list volume
DISKPART> select volume 4
DISKPART> remove letter=G
# To change a drive letter:
DISKPART> select volume 4
DISKPART> assign letter=H
Interactive Command Builder
Build Your Command Sequence:
Your Command Sequence:
Click buttons to build your command sequence...
Best Practices
- Always run
list disk
first to verify disk numbers - Double-check disk selection before destructive operations
- Back up important data before any disk operations
- Use
detail disk
to verify you've selected the correct disk - Test commands on non-critical systems first
- Document your disk layout before making changes
Common Mistakes to Avoid
- Selecting wrong disk number (can destroy OS or data)
- Using CLEAN without verifying disk selection
- Forgetting to assign drive letter after formatting
- Not checking for existing partitions before creating new ones
- Attempting to extend volumes without adjacent free space
- Running DiskPart without administrator privileges
Additional Information
Partition Types
- Primary: Bootable partitions (max 4 per MBR disk)
- Extended: Container for logical drives (MBR only)
- Logical: Drives within extended partition
- GPT: Modern partition table (128 partitions, >2TB support)
- MBR: Legacy partition table (4 primary partitions, 2TB limit)
File Systems
- NTFS: Default for Windows, supports large files, permissions
- FAT32: Universal compatibility, 4GB file size limit
- exFAT: For flash drives, no file size limit
- ReFS: Resilient File System for servers
Pro Tip
DiskPart scripts can be automated by saving commands in a text file and running: diskpart /s scriptfile.txt
Quick Reference Card
Information Commands
list disk
list volume
list partition
detail disk
detail volume
Selection Commands
select disk X
select volume X
select partition X
Action Commands
clean
create partition primary
format fs=ntfs quick
assign letter=X
extend
shrink