Logo


Managing recovery partitions.

How to Clean, partition and format W7 Disks with the Diskpart Command

information   Information
This will show you how to use the clean 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. It is only marked as being deleted and can be written over when new data is written/saved to the HDD next.

OR


You can 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 sanatize and delete all data on the disk. This option takes longer to do, but is the best option to help ensure that the data on the disk has been removed and not just marked as deleted.
Note   Note
warning   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 help reduce it's life span.




Here's How:
1. To Verify the Disk Number to Clean
warning   Warning
Be sure that you have the correct Disk #. You would not want to wipe clean the wrong disk.
A) Open the Start Menu, then right click on Computer and click on Manage.

B) If prompted by UAC, click on Yes.

C) Click 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.
Disk - Clean and Clean All with Diskpart Command-computer_management-1.jpg
D) Look under the Disk # (ex: Disk 3) in the left part of the middle pane, and check to make sure it says Online. If it doesn't, then right click on Disk # and click on Online to make it so. (see screenshots below)
Disk - Clean and Clean All with Diskpart Command-online.jpgDisk - Clean and Clean All with Diskpart Command-offline.jpg

2. Boot to a WinPE7 disk (Email Geoff for one if you haven't got one)
Open a elevated command prompt, or a command prompt at boot
<< You can use your Boot image CDrom (if you have a WDS boot disk) ... just boot to it as normal then select 'Cancel' when you come to the final image selection menu >>
.

3. In the elevated command prompt, type diskpart and press Enter. (see screenshot below)

Disk - Clean and Clean All with Diskpart Command-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.
Disk - Clean and Clean All with Diskpart Command-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.
Disk - Clean and Clean All with Diskpart Command-step3.jpg
6. To Use the Clean Diskpart Command
A) In the elevated command prompt, type clean and press Enter. (see screenshot below)
NOTE: This will not take long to finish. Think of it being like a quick format.
Disk - Clean and Clean All with Diskpart Command-step4_clean.jpg
 
7. You will now need to create a new partition or volume on the disk to be able to use it again.
Note   Note
A primary partition is a type of partition created on a hard drive that can have a operating system installed on it. A primary partition functions as though it were a physically separate hard drive. By default on a MBR disk, you can create a maximum of 3 Primary partitions and 1 Extended partition with up to 128 logical volumes in the extended partition on a single hard disk


8. In the elevated command prompt, type create partition primary and press Enter. (See screenshot below)
NOTE: This will create a new blank RAW partition with selected disk (step 5) that contains the unallocated partition free space.
Partition or Volume - Create New-cmd_create_step4.jpg
9. In the elevated command prompt, type list volume and press Enter. (See screenshot below)
NOTE: Look for the volume number that has the same Size as from the Free space in step 4. For example, Volume 3.
Partition or Volume - Create New-cmd_create_step5.jpg
10. To Format the Partition or Disk as a NTFS File System
NOTE: This would be good for using with Windows 7 or Vista for example.
A) In the elevated command prompt, type format fs=ntfs quick and press Enter. (See screenshot below)
NOTE: Having quick added at the end of the command will do a quick format instead of a full format on the new blank RAW partition (step 6) to make it a new partition.

Partition or Volume - Create New-cmd_create_step6.jpg


13: Type exit to exit DISKPART.
You can now image the machine.