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:
Brink

Yes I have another computer. Could you provide me the guide to format within Window.

Thank you
 

My Computer

OS
Windows 7 Professional 32bit
If I may?

It's actually unnecessary to specify a partition size with the create partition primary command if your intention is simply to create a single partition spanning the entire disk. The above command will do this on its own if you simply leave the "size=X" option out.

Also, cmlow - were you the person who said it was taking 10 hours to clean all a 160GB harddisk? I'm really concerned because a disk of that size should finish cleaning much sooner. I'd expect at most 3-4 hours - something is wrong if it actually takes 10 or more.

I just wanted to point this out for Brink to comment further on. (Personally I wonder if the HD is running in DMA mode as it should.)
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom-built
OS
Windows 7 Professional SP1 32-bit
CPU
Intel Core 2 Duo E6600 2.4GHz
Motherboard
Asus PL5D2
Memory
4GB DDR2-667 (4x1GB in dual-channel config)
Graphics Card(s)
nVidia GeForce 9800 GT
Sound Card
Creative X-Fi XtremeMusic
Monitor(s) Displays
Acer P236H
Screen Resolution
1920x1200 (DVI)
Hard Drives
OCZ SSD Vertex Plus 60GB SATA (Firmware 3.55), 64MB cache
Hitachi HD321KJ SATA, 320GB, 7200rpm, 16MB cache
PSU
Antec TruePower 2.0
Case
Cooler Master Centurion
Cooling
Too many fans
Keyboard
Standard
Mouse
Microsoft wireless optical mouse
Internet Speed
AT&T U-verse (18mbit/sec)
Antivirus
Microsoft Security Essentials
Browser
Firefox
Other Info
Other devices:
Compaq CQ-60 laptop
Google Nexus 7 (2012) tablet
Nvidia SHIELD tablet (US/LTE)
Hardkernel ODROID-XU single-board computer (Samsung Exynos 5420)
Hi Corazon

Thank you for sharing invaluable experience. I done Clean All for more than 10 hours but then interrupted the process half way. Likewise I also done Format (not quick) and it progressed so slow at the speed of 2% per hour. It is unbelievable.

What is opinion and how to solve my problem?

I appreciated if you could provide some guide in my situation.

Thank you
 

My Computer

OS
Windows 7 Professional 32bit
cmlow,

How does the disk look in Disk Management (diskmgmt.msc)? Could you post a screenshot of it?
 

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
Disaster. I connected the HDD to another computer just thinking to perform DiskManagement as you suggested. Now my another computer's Window is failed to start. It appeards that the file: Boot\BCD is missing.

That is too bad. I got to borrow from someone Window Installation disc to repair it.
 

My Computer

OS
Windows 7 Professional 32bit
cmlow,

It sounds like the HDD may be dead instead. Does the other computer work fine with only it's HDD(s) connected and without your HDD connected to it?
 

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
Yes. The computer is working fine all along.

Here is what I had done to the other HDD:
- Set the jumper to Master, the BIOS shows total HDD size has increased by such, but can't boots up the system

Then I changed the jumper to Cable Select, the Window did System Repair and then finally came to "Window is failed to start. file: Boot\BCD is missing".

Is it the HDD dead. But in List Volume, it shows Healthy. That is weird, right? What is the reason?
 

My Computer

OS
Windows 7 Professional 32bit
cmlow,

You should be able to go to the HDD's brand manufacturer's site to look for a free HDD diagnostic program specific for that brand and model to help see if the HDD is actually dead or what may be wrong with it. If you could post back with the brand and model # of the HDD, we may be able to help find the link for the diagnostic program.
 

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
Excellent tutorial Brink, I will try this and let you know how it went for me.

Thank you.


Xgen
 

My Computer

OS
Windows 7 Ultimate 32bit
You're welcome Xgen, and welcome to Seven Forums. I hope it helps. :)
 

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
cmlow,

You should be able to go to the HDD's brand manufacturer's site to look for a free HDD diagnostic program specific for that brand and model to help see if the HDD is actually dead or what may be wrong with it. If you could post back with the brand and model # of the HDD, we may be able to help find the link for the diagnostic program.

Hi Brink

Here are the information. I hope it would help to find out the cause of reason:

Seagate
Barracuda 7200.7 160GB
Model: ST3160021A
S/N: 4JS1WNL3
P/N: 9102001-371
HDA P/N: 100316766
Cong: D8H-02
Firmware: 8.01

Thanks
 

My Computer

OS
Windows 7 Professional 32bit
Here's the download link for SeaTools to test your HDD with. I'd recommend using the one for DOS.

SeaTools | Seagate
 

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 Brink

I will test it out when getting home. Will keep you in post of the outcome.
 

My Computer

OS
Windows 7 Professional 32bit
I tested the HDD with the SeaTool. It PASSED. No problem. I also used the tool to Max the size, of which I guess it is reformating.

Yet, I still failed to re-image the system as it couldn't find the drive. sigh
 

My Computer

OS
Windows 7 Professional 32bit
cmlow,

I'm not sure why it's not finding the HDD. You might create a new thread on this issue to see if we may be able to give more specific help on it since it's not related to this tutorial. :(
 

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
cmlow,

I'm not sure why it's not finding the HDD. You might create a new thread on this issue to see if we may be able to give more specific help on it since it's not related to this tutorial. :(

Thanks Brinks

By the way, how to start a new thread?:(
 
Last edited by a moderator:

My Computer

OS
Windows 7 Professional 32bit

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
Any idea how this is done without an Operating System?
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Novatech iRush Pro
OS
Windows 7 Ultimate SP1 - 64 Bit
CPU
Intel Core i5 2500k
Motherboard
Foxconn H67M-S/H67M-V/H67
Memory
2x4GB DDR3 1333Hz
Graphics Card(s)
Ati Radeon 6770
Sound Card
None
Monitor(s) Displays
Samsung S22B150
Screen Resolution
1920x1080
Hard Drives
2x500GB
PSU
500W
Cooling
Fan
Keyboard
HP KU0316
Mouse
Wireless Logitech M185
Internet Speed
20MB/s
Antivirus
Avast Free
Browser
Google Chrome
Other Info
Logitech M185 Mouse
KU-M316 Keyboard
Any idea how this is done without an Operating System?

Boot from a Windows install disk and hit Shift and F10 keys when you come to the screen where you are asked to choose a language. That will drop you into a command prompt, from which you can run Diskpart.
 

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.
Does Diskpart DoD wipe the MBR?

Can someone please confirm whether Diskpart will indeed wipe a drive's Master Boot Record and ALL partitions, including hidden ones (created by a trojan)? I've heard mixed things.

I need to do a full-format and DoD wipe of an infected internal SATA HD. It's only a few months old.

A friend suggested DBAN... I downloaded it and created a bootable ISO. However, after starting it up, it's looking for USB drives, and it doesn't recognize my internal HD ("missing a driver"?). Also, based on this video, it appears that DBAN might not be able to get rid of and wipe an "OEM" partition: Using Darik's Boot and Nuke (DBAN) to totally wipe a drive (Hacking Illustrated Series InfoSec Tutorial Videos)

Can someone recommend a bootable HD wiper which would be sure to delete/zero out EVERYTHING, including the MBR? Should I try Ubuntu in Linux? Thanks.
 

My Computer

OS
Win7 Pro x64
Back
Top