Drive Restorer
Windows 10 & 11 Buy license · $29.95
Drives and devices

Ran Diskpart Clean on the Wrong Disk? How to Recover Your Files

Ran diskpart clean on the wrong disk? The clean command wipes the partition table, not the data. Here is what to do next and how to recover the files.

Updated 4 minute read The Drive Restorer team

If you ran diskpart clean on the wrong disk, your files are usually still recoverable. The clean command only removes the partition table and related information at the start (and, on GPT disks, the end) of the disk; it does not touch the data area. Stop right there: do not create partitions, initialize the disk or format it. Scan the disk with partition search software, recover the old partitions' files to a different drive, and only then rebuild the disk. clean all is different: it writes zeros to every sector, and the data cannot be recovered with software.

Here is exactly what each command does, what to avoid and how to get your files back.

clean vs clean all

CommandWhat it doesTime takenRecovery with software
cleanRemoves partition and volume information from the diskA second or twoUsually possible on hard drives and USB drives
clean allAlso writes zeros to every sectorHours on a large driveNot possible once complete
clean all, stopped part wayZeros written from the start of the disk up to where it was stoppedVariesOnly for data beyond the point it reached

The clue is how long it took. If diskpart said "DiskPart succeeded in cleaning the disk" almost instantly, you ran plain clean.

SSDs are the exception. On many SSDs, Windows tells the drive that the whole disk is now unused when it is cleaned, and the SSD may then erase the data in the background, much as TRIM does after a delete. Recovery from a cleaned internal SSD is often not possible. Scan it as soon as you can, but expect less.

What the disk looks like now

After clean, Disk Management shows the disk as Unknown and Not Initialized, with all its space unallocated. Windows may pop up an Initialize Disk prompt. File Explorer no longer shows any of its drive letters. The files are still physically on the disk; Windows has simply lost the map that told it where the partitions began and ended.

What not to do next

  • Do not initialize the disk. Click Cancel on the Initialize Disk prompt. Initializing writes a new partition table.
  • Do not create new partitions or volumes. Each new volume gets a new file system written into the area where your old one lived.
  • Do not format. A quick format overwrites the old file system records that hold your file names and folders.
  • Do not run diskpart again to "fix" it with create or convert commands.
  • Do not reinstall Windows onto it, if it was the system disk.

Each of these writes new data to the disk. They may not destroy everything, but they make it harder to get files back with their original names.

How to recover the files

A cleaned disk is a lost-partition problem. Drive Restorer includes a partition search that finds partitions that have disappeared and recovers the files on them, even when the disk shows as completely empty.

  1. Connect the disk to a working Windows PC if it is not already. If you cleaned your Windows system disk, connect it to another PC as a second drive.
  2. Select the physical disk in Drive Restorer. It has no drive letter now, so pick it by its size and model.
  3. Run the partition search. It scans the disk for the boot sectors and file system structures of old NTFS, exFAT and FAT32 partitions.
  4. Open each partition found and browse it. If the file system is intact, you will see your folders with their original names.
  5. Run a deep scan if a partition is not found or a folder is missing. It finds files by their content across the whole disk, though without names.
  6. Preview important files and check the recovery chance rating.
  7. Restore everything to a different drive with enough space. Nothing is written to the cleaned disk.

On a large disk, save the scan so you can resume it later rather than starting again.

If you already initialized or formatted it

Do not panic, and do not do anything more. Initializing alone rarely touches the data area, and a partition search usually still finds the old partitions. If you also created a volume and quick-formatted it, the old file system records near the start of each partition may be overwritten, so names and folders may be lost, but a deep scan can still find many files by their content. A full format, which writes zeros across the volume, erases the data. Our guide to recovering data from a formatted hard drive covers that case in detail.

Rebuilding the disk afterwards

When your files are copied off and checked:

  1. In Disk Management, right-click the disk and choose Initialize Disk. Pick GPT for most drives, and always for drives over 2 TB.
  2. Right-click the unallocated space and choose New Simple Volume to create and format a partition.
  3. Copy your recovered files back if you want them there.

For more on the initialize prompt and the MBR or GPT choice, see disk not initialized: recover data first.

How to avoid cleaning the wrong disk

Diskpart does not ask for confirmation. The safe habit is to check twice before any destructive command:

  1. Run list disk and note each disk's size.
  2. Unplug any external drives you are not working on.
  3. After select disk N, run detail disk. It shows the model name and the volumes on the disk, with their letters and labels.
  4. Only then run clean.

Disk numbers can change between reboots and when drives are plugged in, so never rely on a number you noted earlier. If you are preparing a USB stick, using Disk Management or the Format option in File Explorer is less risky, because you can see exactly which drive you are working on. For other ways partitions go missing, read how to recover a lost partition.

Frequently asked questions

Does diskpart clean erase data?

The clean command removes the partition table and leaves the data area intact. Clean all writes zeros to every sector, which erases the data.

Can I undo diskpart clean?

There is no undo command, but partition search and recovery software can often find the old partitions and the files on them.

What should I avoid after running clean?

Do not create new partitions, initialize again or format. Each of these writes new data to the disk.

Get three guides like this every month, plus software update notices.Subscribe →