WHAT IS: DiskPart Clean and/or Clean All Function?
The clean function in DiskPart is a command used to remove all partitions or volumes from a disk, essentially wiping out all existing data on the disk. When you use clean in DiskPart on a particular disk, it performs the following actions:
Removal of Partitions: Deletes all partition or volume structures from the selected disk. This includes removing any partition tables and file systems information – or said another way, removes the format of the drive.
Data Erasure: The clean command deletes the partition table entries and boot code, but does NOT erase any data or overwrite data with random bits. Meaning, after using the clean command a data recovery software package could still recover the data.
Disk Initialization: After executing clean, the disk is left uninitialized. This means that the disk does not have any partitions or volumes, and it appears as raw, unallocated space. In order to use the drive after a DiskPart clean it is required to go into Windows Disk Management tool and assign a new volume to the USB. Once this is done, the device will have a file system (format) and be usable.
The CLEAN function is a nice way to quickly erase the partition and file system to start fresh with a new drive. For example, if an IMG file that is 5GBs large written to a 32GB stick, the problem is that 32GB stick is now only 5GBs large. The remaining space on the USB is unallocated and not usable. To get that unallocated space back, run the DiskPart CLEAN command. You will now have a 32GB drive (after initialization in Disk Management).
The clean all function in DiskPart is similar to the clean function but with an additional step of overwriting the entire disk with zeros. When you use clean all, DiskPart performs the following actions:
Removal of Partitions: Like clean, clean all deletes all partition or volume structures from the selected disk, removing any existing partition tables, file systems, and associated data.
Data Overwriting: In addition to removing the partitions, clean all also writes zeros to every sector of the disk. This process effectively erases all data on the disk by overwriting it with zeros. The purpose of this step is to securely erase the disk’s contents, making data recovery extremely difficult or impossible using standard methods.
Disk Initialization: After executing clean all, the disk is left uninitialized and completely wiped clean. It appears as raw, unallocated space with all previous data erased.
The clean all command is a more secure method of erasing data compared to clean alone, as it ensures that all sectors of the disk are overwritten with zeros. This process takes more time than clean because of the data overwriting step.
TIP: As with clean, it’s crucial to use clean all with care. Verify that you are selecting the correct disk because executing clean all on the wrong disk will result in irreversible data loss.
Ref: DiskPart Wikipedia