How to Remove All Partitions from a Specific Disk Using DiskPart in Windows
QUICK ANSWER To remove all partitions from a particular physical disk, open Command Prompt or Windows Terminal as Administrator, start DiskPart, identify the...
QUICK ANSWER
To remove all partitions from a particular physical disk, open Command Prompt or Windows Terminal as Administrator, start DiskPart, identify the correct disk with list disk, select it, verify it with detail disk, and then run clean. Microsoft documents clean as removing all partitions or volume formatting from the disk currently selected in DiskPart.
Example:
diskpart
list disk
select disk 2
detail disk
clean
exit
Replace 2 with the actual target disk number. This is destructive: clean removes the disk's partition information, making the existing partitions and their data inaccessible. Verify the disk number and size before running the command. Microsoft specifically recommends backing up or moving important data before cleaning a disk.
COMPLETE ARTICLE
How to Remove All Partitions from a Specific Disk Using DiskPart in Windows
What Is DiskPart?
DiskPart is a built-in Windows command-line utility for managing disks, partitions, volumes, and virtual disks. It can be used to create, delete, format, resize, convert, and clean storage devices.
One of its most useful commands for disk reconfiguration is:
clean
When executed against a selected disk, clean removes the disk's partition or volume formatting. This is useful when you want to completely remove the existing partition layout and start again with an unallocated disk.
Typical situations include:
- Reusing an old hard drive.
- Preparing a disk for a fresh Windows installation.
- Removing an incorrect or unwanted partition layout.
- Converting a disk between partition configurations.
- Preparing a secondary disk for new partitions.
- Removing old partitions before creating a new GPT or MBR layout.
- Troubleshooting a disk whose existing partition structure is causing management problems.
Important Warning Before Using DiskPart
DiskPart operates directly on storage devices. Selecting the wrong disk can result in permanent data loss.
Before running clean:
- Back up anything important.
- Disconnect unnecessary external drives if possible.
- Use
list diskto identify the target. - Check the disk's size and other identifying information.
- Run
detail diskafter selecting it. - Only run
cleanafter confirming that the selected disk is the correct one.
Microsoft states that the clean operation permanently destroys the data associated with the selected disk and recommends backing up or moving important data first.
Do not assume that Disk 1, Disk 2, or another number always refers to the same physical drive. Disk numbers can vary between computers and configurations.
Prerequisites
You generally need:
- Windows 10, Windows 11, or a supported Windows Server version.
- Administrator privileges.
- The correct physical disk identified.
- A backup of any data that needs to be retained.
Microsoft notes that DiskPart requires membership in the local Administrators group or equivalent permissions.
Step 1: Open Command Prompt as Administrator
Open Command Prompt, Windows Terminal, or PowerShell with administrator privileges.
Then run:
diskpart
You should see the DiskPart prompt:
DISKPART>
Step 2: List All Disks
Run:
list disk
Example:
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 476 GB 0 B
Disk 1 Online 931 GB 931 GB
Disk 2 Online 1863 GB 1863 GB
The displayed disk number is the number you will use with select disk.
The Size column is particularly useful when several disks are installed.
Step 3: Select the Target Disk
For example, to select Disk 2:
select disk 2
DiskPart should report:
Disk 2 is now the selected disk.
Microsoft explains that DiskPart commands operate on the object that currently has focus. Therefore, selecting the correct disk is critical before executing destructive commands.
Step 4: Verify the Selected Disk
Before deleting anything, run:
detail disk
This provides additional information about the selected disk and its volumes. Microsoft specifically recommends using detail disk to verify the disk before cleaning it.
Check:
- Disk model
- Disk size
- Disk status
- Read-only status
- Boot/system information
- Listed volumes
- Other identifying information
If anything does not match the disk you intend to erase, stop.
Do not run clean until you have confirmed the correct physical disk.
Step 5: Remove All Partitions
Once the correct disk has been selected and verified, run:
clean
Example:
DISKPART> clean
DiskPart succeeded in cleaning the disk.
The clean command removes all partitions or volume formatting from the disk that currently has focus.
Afterward, you can verify the result with:
list disk
The target disk should normally show its capacity as free/unallocated space.
You can also use:
list partition
to inspect the partition layout.
Complete Command Sequence
For example, if the target disk is Disk 2:
diskpart
list disk
select disk 2
detail disk
clean
list disk
exit
The most important safety step is the verification between select disk 2 and clean.
What Happens After clean?
After clean successfully completes:
- Existing partitions are removed from the disk's partition layout.
- Existing volumes are no longer available through their previous partitions.
- Windows will generally see the disk as containing unallocated space.
- The disk can subsequently be partitioned and formatted again.
clean does not create a new partition or format the disk for normal file storage. You must create a new partition and format it if you want to use the disk again.
For example:
diskpart
select disk 2
clean
create partition primary
format fs=ntfs quick
assign
exit
The create partition primary and format commands are separate operations from clean. Microsoft documents DiskPart commands for creating partitions and formatting them after a disk has been prepared.
clean vs. clean all
DiskPart supports:
clean
and:
clean all
They should not be treated as identical operations.
| Command | Main purpose | Operation |
|---|---|---|
clean |
Remove existing partition/volume formatting | Removes partition information from the selected disk |
clean all |
Zero the disk's sectors | Writes zeros to every sector |
Microsoft documents clean all as setting every sector on the disk to zero.
When should you use clean?
Use:
clean
when your goal is primarily to remove the existing partition layout and prepare the disk for repartitioning.
It is generally much faster than writing across the entire disk.
When should you use clean all?
Use:
clean all
when you specifically need DiskPart to write zeros across the disk.
Example:
diskpart
list disk
select disk 2
detail disk
clean all
exit
This can take considerably longer because the entire disk is written.
Important:
clean allshould not simply be described as a universal "secure erase" solution for every type of storage device. SSDs and other flash-based storage use internal storage-management mechanisms, so requirements for secure sanitization can differ from conventional hard-disk drives.
Does clean Delete the Files?
clean removes the disk's partition information and makes the existing partition structure unavailable. It is therefore a destructive operation.
However, clean is different from writing zeros to every sector. Microsoft documents clean all separately as the operation that zeroes every sector.
Therefore:
- Need to remove partitions and reuse the disk? Use
clean. - Need to zero every sector? Use
clean all. - Need formal secure sanitization of an SSD or organizationally managed storage device? Follow the storage manufacturer's and organization's approved sanitization procedure rather than assuming
clean allis sufficient.
What If the Disk Is Read-Only?
First select the disk:
select disk 2
Then inspect its attributes:
attributes disk
Microsoft documents attributes disk for displaying, setting, and clearing disk attributes.
If the disk is software-marked as read-only, you can clear that attribute with:
attributes disk clear readonly
Then try:
clean
However, if the device has a physical write-protection switch, hardware failure, controller issue, or other protection mechanism, clearing the DiskPart attribute may not resolve the problem.
What If clean Says the Disk Is Write-Protected?
Check:
attributes disk
If it reports:
Read-only : Yes
try:
attributes disk clear readonly
Then verify again:
attributes disk
If it still cannot be written to, investigate the storage device itself.
Possible causes include:
- Hardware write protection.
- Faulty storage media.
- USB adapter or enclosure problems.
- Storage-controller problems.
- Organizational security controls.
- A disk that has entered a failure state.
Do not repeatedly force destructive operations against a disk that may be failing if its data is important.
What If You Accidentally Select the Wrong Disk?
Do not run clean.
Simply select the correct disk:
list disk
select disk X
detail disk
Then verify it again.
DiskPart maintains a current object focus, and subsequent commands can operate on that selected object.
Can You Remove Partitions Individually Instead?
Yes.
DiskPart also supports partition-level operations. You can use:
list partition
to view partitions on the selected disk and then select a particular partition.
For example:
select partition 3
However, if the objective is specifically to remove all partitions from the entire disk, clean is usually more direct than deleting partitions one by one. Microsoft documents select partition and other partition-management commands separately.
clean vs. Deleting Partitions One by One
| Approach | Best used for |
|---|---|
clean |
Removing the complete partition layout from a disk |
delete partition |
Removing a particular partition |
| Disk Management | Graphical partition management |
PowerShell Clear-Disk |
PowerShell-based disk management and automation |
For example, Microsoft provides this PowerShell alternative for removing partitions and volumes:
Clear-Disk -Number <Disk Number> -RemoveData -Confirm:$false
Microsoft documents Clear-Disk as a PowerShell alternative for preparing a disk by removing its partitions and volumes.
Using DiskPart for a New GPT Disk
A common workflow after cleaning a disk is to create a GPT partition table:
diskpart
list disk
select disk 2
detail disk
clean
convert gpt
exit
Microsoft documents clean followed by partition-style conversion as part of disk preparation.
GPT is generally the preferred partition style for modern Windows systems, while MBR remains relevant for compatibility with older systems and specific legacy configurations.
Preparing a Disk for Windows Installation
DiskPart can also be used from Windows Setup or Windows PE when preparing a disk for installation.
A typical controlled workflow is:
diskpart
list disk
select disk 0
detail disk
clean
convert gpt
exit
Do not blindly use select disk 0 in documentation or deployment scripts. Disk numbering depends on the machine's storage configuration.
On systems with multiple drives, Microsoft recommends using identifying information such as disk details and, in deployment scenarios, physical location information when necessary to distinguish drives.
Important Difference: clean Is Not a Format
A common misconception is that:
clean
formats a disk.
It does not.
clean removes the existing partition/volume formatting information from the selected disk. Formatting is a separate operation.
For example:
clean
create partition primary
format fs=ntfs quick
assign
These represent separate stages:
- Remove the old partition layout.
- Create a new partition.
- Create a filesystem.
- Assign a drive letter.
Recommended Safe Workflow
For routine disk reuse, the safest general workflow is:
diskpart
list disk
select disk X
detail disk
clean
exit
Replace X only after confirming the correct disk.
For a disk that will immediately be used as a new GPT disk:
diskpart
list disk
select disk X
detail disk
clean
convert gpt
exit
The exact partitioning and formatting steps afterward depend on how the disk will be used.
Troubleshooting
"There is no media in the device"
This can occur with certain removable-media devices, card readers, USB adapters, or faulty storage hardware. Check the physical connection and verify the disk using:
list disk
detail disk
"The request could not be performed because of an I/O device error"
This may indicate a communication or hardware problem involving the disk, controller, cable, USB enclosure, or storage media.
Check the physical connection and Windows storage diagnostics before repeatedly attempting destructive operations.
"DiskPart has encountered an error: Access is denied"
Possible causes include:
- Command Prompt was not opened as Administrator.
- The disk is being used by Windows or another application.
- The storage device has write protection.
- Security or organizational controls are preventing the operation.
Start by verifying administrator privileges and running:
attributes disk
The disk still appears in Disk Management
That is expected if the physical disk is still connected. clean does not physically remove the disk from the computer.
Instead, Windows should show the disk without its previous partitions, typically as Unallocated space.
Windows still shows an old drive letter
Refresh Disk Management or use DiskPart to inspect the current disk and volume configuration.
If necessary:
diskpart
rescan
list disk
Microsoft documents rescan as a DiskPart command for locating newly added disks.
Benefits of Using DiskPart
DiskPart is useful because it provides:
- Built-in Windows functionality — no third-party partitioning software is required.
- Precise disk selection — disks can be explicitly selected before operations.
- Command-line operation — useful for administrators and deployment environments.
- Automation support — DiskPart commands can be placed in scripts.
- Partition-style management — useful when preparing GPT or MBR disks.
- Recovery and installation workflows — it can be used from suitable Windows setup or recovery environments.
Microsoft also supports DiskPart scripts using:
diskpart /s scriptname.txt
which can be useful for controlled administrative and deployment tasks.
Limitations and Safety Considerations
DiskPart is powerful but intentionally low-level.
Keep these points in mind:
- It does not provide the same visual safeguards as graphical disk-management software.
- A wrong disk selection can cause destructive results.
cleanremoves the partition layout.clean allwrites zeros across the disk and can take a long time.- Cleaning a system disk from the running Windows installation may not be possible because Windows is actively using it.
- SSD sanitization requirements can differ from traditional HDD wiping.
- Data that is important should be backed up before destructive disk operations.
Best Practice for IT Professionals
For administrative or deployment environments, avoid scripts that blindly assume a disk number.
For example, a script containing:
select disk 1
clean
can be dangerous if the hardware configuration changes.
Instead, establish a reliable method of identifying the intended disk using size, model, serial information, physical location, or other deployment-specific identifiers before performing destructive operations. Microsoft documents physical location paths as one method of distinguishing drives in multi-disk deployment scenarios.
For automated workflows, test the process on representative hardware before deploying it broadly.
FAQ
1. What DiskPart command removes all partitions from a disk?
Use:
select disk X
clean
clean removes all partitions or volume formatting from the selected disk.
2. Does clean delete all data on the disk?
It removes the partition information and makes the existing partitions inaccessible. It is destructive, but it is not the same operation as writing zeros to every sector. clean all is the DiskPart command that writes zeros across the disk.
3. Is clean all better than clean?
They serve different purposes. Use clean when you primarily need to remove the partition layout. Use clean all when you specifically require every sector to be zeroed.
4. How do I make sure I select the correct disk?
Run:
list disk
select disk X
detail disk
Verify the disk's size, model and other information before running clean. Microsoft specifically recommends verifying the selected disk before cleaning it.
5. Can I use DiskPart without Administrator rights?
DiskPart requires administrator-level permissions or equivalent permissions.
6. What happens to the disk after clean?
Its existing partition layout is removed. Windows will generally show the disk as unallocated, allowing you to create new partitions.
7. Can I recover data after using clean?
Do not rely on recovery after a destructive DiskPart operation. If the data is important, stop using the disk and use an appropriate professional data-recovery process rather than continuing to write data to it.
8. Can I use DiskPart to prepare an SSD?
Yes. DiskPart can manage SSDs, including removing partitions. However, requirements for secure sanitization of SSDs can differ from those for HDDs, so clean all should not automatically be treated as a complete SSD sanitization strategy.
9. Can I use PowerShell instead of DiskPart?
Yes. Microsoft provides Clear-Disk for PowerShell-based disk management. For example:
Clear-Disk -Number 2 -RemoveData -Confirm:$false
The disk number must be verified before running the command.
10. Can clean remove the Windows system disk?
A disk containing the currently running Windows installation generally cannot simply be cleaned from that running installation because the operating system is using it. For installation or recovery scenarios, use an appropriate Windows Setup or Windows PE environment and carefully identify the intended disk.
FINAL RECOMMENDATION / CONCLUSION
For the straightforward task of removing all partitions from a particular secondary disk, the recommended DiskPart workflow is:
diskpart
list disk
select disk X
detail disk
clean
exit
The critical step is not the clean command itself—it is correctly identifying and verifying the target disk before executing it. Use clean when you need to remove the partition layout, and use clean all only when you specifically need every sector zeroed. For SSDs or formal data-sanitization requirements, follow the storage manufacturer's or organization's approved sanitization procedure.
#DiskPart #Windows #Windows11 #Windows10 #DiskManagement #PartitionManagement #HardDrive #SSD #DiskCleanup #CleanDisk #CleanAll #DataWiping #GPT #MBR #StorageManagement #WindowsCommands #SystemAdministration #ITSupport #PowerShell #ComputerMaintenance
SOURCES — list the authoritative sources used, or write “No external sources required”
Was this guide useful?
Your answer helps us keep BISONKB accurate and practical.