Disk - Clean and Clean All with Diskpart Command

How to "Clean" or "Clean All" a Disk with the Diskpart Command


   Information
This will show you how to use the clean or clean all command on a selected disk to delete all of it's MBR or GPT partitions, volumes, and any hidden sector information on MBR disks is overwritten.

The data on the HDD is not written over using the clean command like it does with the clean all command below. With the clean command, the data on the HDD is only marked as being deleted instead and is only written over when new data is written/saved to the same location on the HDD next.

OR

You could use the clean all command (secure erase) to do the above and also have each and every disk sector on the HDD written over and zeroed out completely to securely delete all data on the disk to help prevent the data from being able to be recovered. "Clean All" takes about an hour per 320 GB to finish running.

   Note

  • You cannot use the clean or clean all diskpart commands on a boot disk (ex: disk Windows is installed on) unless you do it from a command prompt at boot.
  • Be sure to backup anything that you do not want to lose on the disk that you use clean or clean all on first. It will be to late afterwards. All data will be permanently lost on the disk.
   Warning
You do not want to use clean all on a SSD disk often. Having every sector written over to 0 on a SSD can reduce it's life span faster.





Here's How:

1. In Windows 7, open an elevated command prompt, or a command prompt at boot.

OR

2. In Windows 8 and 8.1, open an elevated command prompt, or a command prompt at boot.

   Note
Be sure that you have the correct Disk #. You would not want to wipe clean the wrong disk.

A) Press the Windows + R keys to open the Run dialog, type compmgmt.msc, and press Enter.

B) If prompted by UAC, click/tap on Yes.

C) Click/tap on Disk Management in the left pane, and make note of the disk # in the middle pane of the disk that you want to clean or clean all. (see screenshot below)
NOTE: For example, I would use Disk 1 if I wanted to use clean or clean all on my USB key drive.
Computer_Management-1.jpg


3. In the elevated command prompt, type diskpart and press Enter. (see screenshot below)
Step1.jpg
4. In the elevated command prompt, type list disk and press Enter. (see screenshot below)
NOTE: This will give you a list of disk numbers to select from.
Step2.jpg
5. In the elevated command prompt, type select disk # and press Enter. (see screenshot below)
NOTE: You would substitute # for the disk number listed that you want to use clean or clean all on. For example, I want to use one of them on Disk 1 (from step 1) for my USB key drive, so I would type select disk 1 and press Enter.
Step3.jpg
6. If the status of the selected disk # (ex: Disk 3) shows as Offline, type online disk, and press Enter to make it online. (see screenshot below)
diskpart_online_disk.png
7. Do either step 8 or 9 below for which command you would like to use.


8. To Use the Clean Diskpart Command
NOTE: (Recommended) See the green INFO box at the top of the tutorial for more information about this command. This command will wipe the HDD quickly.
A) In the elevated command prompt, type clean, press Enter, and go to step 10 below. (see screenshot below)
NOTE: This will not take long to finish. Think of it as being like a quick format.
Step4_Clean.jpg
9. To Use the Clean All Diskpart Command
NOTE: See the green INFO box at the top of the tutorial for more information about this command. This command will wipe the HDD, and perform a secure erase. "Clean All" takes about an hour per 320 GB to finish running. It's best to only use this command if you wanted to help make sure that the data on the HDD cannot be recovered say when giving or selling the HDD to another person.
A) In the elevated command prompt, type clean all, and press Enter, and go to step 10 below. You will see the command prompt below as is until the "clean all" command is finished. (see screenshot below)

NOTE: This will take quite some time (several hours or more) to finish depending on how large the disk is since it is writing over each and every sector on it to zero. Think of it as being like a full or low level format.
Step4_Clean_All.jpg
10. When finished, in the elevated command prompt, type exit and press Enter. Close the elevated command prompt.

11. The disk will be left as unallocated space. (see screenshot below)
Computer_Management-2.jpg
12. You will now need to create a new partition or volume on the disk to be able to use it again.



That's it,
Shawn







 
Last edited:
Just as we have been exchanging this mail, clean all command finished, so all is well now. Thanks for your help anyway. Just for the others who will possibly do this, the clean all process was 5 hours long for me.
 

My Computer

Computer type
PC/Desktop
OS
Windows 7 Ultimate
Great news. :)

Yeah, "Clean all" take a long time to finish, and should really only be used if you're giving or selling the drive to someone else.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
A VERY useful tutorial indeed. :D
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Hybrid
OS
Win7 SP1 + Ultimate 64 bit
CPU
Intel G3258
Motherboard
GA Z97X Gaming 3
Memory
32gb Gskill
Graphics Card(s)
GTX 660Ti EVGA x 2
Monitor(s) Displays
Asus 23" LCD Widescreen
Screen Resolution
1920/1080
Hard Drives
1 x Samsung EVO840 250gb SSD
1 X 1 TB Velociraptor
1 x 1 Seagate 7200rpm
PSU
750W Thermaltake
Case
Thermaltake A60
Cooling
Xigmatek Dark Knight CPU and stock case fans
Keyboard
Alienware
Mouse
Microsoft USB
Internet Speed
Optusnet Cable
Antivirus
MS, Malwarebytes
Browser
Palemoon 64Bit
Hi all,
How long does Clean command take on 2TB drive, I wonder?
 

My Computer

OS
Windows 7 Ultimate 64bit
CPU
AMD Phenom 8450 Triple-Core 2.10GHz
Motherboard
Gigabyte
Memory
2GB DDR2
Hi all,
How long does Clean command take on 2TB drive, I wonder?

Very quickly---seconds. Similar to a quick format.

Clean all would take hours.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Ignatz Special; 4 speed manual gearbox; factory air conditioning; one of one
OS
Windows 7 Home Premium SP1, 64-bit
CPU
Intel Skylake i5-6600K, not overclocked
Motherboard
AsRock Z170M Extreme 4, micro ATX
Memory
8 GB HyperX DDR4-2666 (2 x 4 GB)
Graphics Card(s)
none; graphics are integrated on CPU
Sound Card
onboard: Realtek ALC1150; external: USB Behringer UF0-202
Monitor(s) Displays
Dell S2340M 23 inch IPS
Screen Resolution
1600 x 900
Hard Drives
System: Crucial MX100 series SSD, 128 GB;
Data: Samsung Spinpoint 103SJ, 1 TB;
Backup: WD Caviar Green WD30EZRX-00D8PB0, 3 TB
PSU
Rosewill SilentNight 500 watt fanless, semi-modular
Case
Antec Solo II
Cooling
Noctua NH-U12S; Noctua F12 intake, Noctua S12A exhaust
Keyboard
Microsoft 200 6JH-00001 USB
Mouse
Dell or Microsoft optical wired; USB
Antivirus
Microsoft Security Essentials and Malwarebytes Premium
Browser
Pale Moon
Other Info
All fans PWM; speeds at idle: CPU circa 500 rpm; intake circa 600 rpm; exhaust circa 600 rpm; CPU temps 27 idle and 47 C load in a warm room (27 C/81 F) when running Intel Extreme Tuning Utility stress test.
Oh, finally I done it on my drive but it took 40 minutes for Clean command :(
 

My Computer

OS
Windows 7 Ultimate 64bit
CPU
AMD Phenom 8450 Triple-Core 2.10GHz
Motherboard
Gigabyte
Memory
2GB DDR2
Thanks for a very interesting discussion and especially Brink for all his input. I have read evry post on this topic and haven't seen my problem discussed. Somehow my 160Gb Western Digital HDD has been reduced to 137Gb of unallocated space by using Clean All with my Windows 7 installation disk. The rest of the space has disappeared as shown by Windows 7 Disk Management, DiskPart(Installation Disk), or Seagate Disk Wizard, with the drive connected to an IDE port or a USB interface. The drive, my Bios, and the USB interface are 48bit LBA capable. Any suggestions?
 

My Computer

Computer type
PC/Desktop
OS
Windows 7 Home Premium 64bit

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
Thanks again Brink for your quick response.:geek: As requested, here are the screenshots of pertinent programs, DiskPart, Windows DiskManagement, and Seagate DiskWizard.

DiskPart1..JPG

DiskPart2.JPG

Disk Management.JPG

Seagate DiskWizard.JPG

I probably confused the issue by stating my drive was limited to 137 GB. The drive is a Western Digital 1600BB-22RDA0, advertised as a 160 Gb drive. This shoud be interpreted as 160 x 10exp9. If you do the math and convert to an exponent of 2exp30 what you will find is that all these programs should tell me the drive is 147 GB. I'm wondering if I did something in DiskPart that wiped out something on the drive used by it for property information. Perhaps someone out there has had a similiar experience.:o
 

My Computer

Computer type
PC/Desktop
OS
Windows 7 Home Premium 64bit
Woody,

I don't see any other partition that could be using the space for your K (Disk 6) drive.

I agree that by the math a 160GB hard drive should show as 147GB, and not 128GB. Possibly a mislabeled drive. If it's still new, I would return it for one that's not shorted.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
In response, I believe this drive had full capacity when I was using it as my system drive. I didn't notice any discrepency until I was experimenting with DiskPart and did a Clean All command.
 

My Computer

Computer type
PC/Desktop
OS
Windows 7 Home Premium 64bit
The "Clean All" command shouldn't have caused this since it basically just secure wipes the drive and makes all available space free.

You could try running the "Clean" (not "Clean All") command again to see if anything else shows up.

You might run chkdsk on the drive to see if it finds any bad sectors. If the hard drive is going bad with a lot of bad sectors, they could have been marked as unusable reducing the available space on the drive.

How old is the drive?
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
hi , i use a windows 7 installation usb. after log in windows installation page, i use Shift+ F10 , and then enter cmd and use "clean all" cmd. it takes about 40 minutes and still blinking now . So, may i know is this command works for the windows installation page ? thnx in advance.
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
toshiba
OS
windows vista home basic
CPU
centrino
hi , i use a windows 7 installation usb. after log in windows installation page, i use Shift+ F10 , and then enter cmd and use "clean all" cmd. it takes about 40 minutes and still blinking now . So, may i know is this command works for the windows installation page ? thnx in advance.

Sorry do not reply. It already done and work perfect in windows installation page. The malware attached to disk which cannot be removed by clean command already gone. Thnx bro.
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
toshiba
OS
windows vista home basic
CPU
centrino
I've used Seagate DiskWizard to clean the disk, used Windows to repartition and long format, and Windows Disk Error Check(no bad sectors), and the drive works flawlessly but still has only 128GB of capacity. It's a spare drive so I'm putiing it away and going on to other projects. Thanks to all who took the time to comment.
 

My Computer

Computer type
PC/Desktop
OS
Windows 7 Home Premium 64bit
Woody,

The only thing I can think of is either a mislabeled drive, or some sort of drive failure/issue.

If it's still under warranty, then you might consider getting an RMA with the manufacturer for a replacement.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
Thanks

Thanks for the article. It was simple and short solution to recover my hard drive.
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Samsung
OS
Windows 7 ultimate 32 bit.
Interrupting "clean all "

Hey,

I decided to do a clean install of my Windows 7 and succeeded in doing so by interrupting "clean all" command using "Ctrl+C" and running the "clean" command.It took just 20 minutes for the process to complete. The "clean all" process was interrupted after 20 mins and the "clean" process hardly took any time to finish cleaning my hard-disk(1TB max;20GB-30GB used). The free-space in the hard-disk was as large as the hard-disk itself which assures me that i haven't done anything wrong, but my gut feeling says otherwise.
Have i done something wrong?Will I encounter any problems in the future?
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
HP
OS
Windows 7 Home Premium x64
CPU
i7
Hello Adithya, and welcome to Seven Forums.

No worries. You didn't do anything wrong, and shouldn't have any problems. If either command is interrupted, then simply repeating either command will let you start over.

"Clean" wipes the drive, and does take long. Think of it like a quick format, but leaves the disk unallocated instead.

"Clean All" does the same thing as "Clean", but also does a 1 pass secure erase. The secure erase is what takes so long. Think of it like a full format, but leaves the disk unallocated instead.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
Thank you,Brink :)
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
HP
OS
Windows 7 Home Premium x64
CPU
i7
Back
Top