Use of DiskPart to Clean the HDD/SSD


This guide has a complimentary tutorial video.

Following the steps in the this guide will remove the partitions from your drive resulting in data loss.

Introduction and Preparation

This guide instructs in using DISKPART to clean any hard drives from Windows Installation Media.

This procedure is necessary if you get the error message during a Windows 7 or 8.1 installation:

We couldn't create a new partition or locate an existing one. For more information, see the Setup log files

This error message seems to be related to differences in GPT and MBR. For example if MBR partitions are setup on the HDD and you try to install in GPT. If you get this error message you can't proceed so exit the setup.

To proceed with this guide you will need either a Dell Windows 7 Reinstallation DVD, a Microsoft Windows 7 Installation DVD, Windows 8.1 with Update 2 or Windows 10 TH2 Installation media.

You need the Windows 64 Bit installation media to be prepared in GPT (for a UEFI BIOS > 2012) or MBR (for a GPT BIOS <2010). For a (2010-2011) you'll need to see if the BIOS has been updated to support UEFI.

Booting from Windows 7, 8.1 and 10 Installation Media

Power down your computer. Hold F12 while powering up your computer (at the Dell BIOS screen).

Dell BIOS Screen

Follow the instructions below to Boot either via UEFI or Legacy respectively.

Variant A: UEFI Boot

If your system is newer than 2012 its recommended to use a UEFI Boot  and a GPT partition scheme; this is faster and more reliable. The boot manager should mention a UEFI Boot similar to below.

Note UEFI may not work with a DVD and you should Install from a USB.

Note Windows 7 64 Bit installation media was never updated to incorporate a Microsoft Digital Signature so is rejected by SecureBoot. SecureBoot has to be disabled for a Windows 7 64 Bit install and Legacy ROMs have to be enabled. Windows 8.1 and Windows 10 have the Microsoft Digital Signature so pass SecureBoot. Its recommended to use SecureBoot with these versions of Windows. To change the UEFI BIOS settings to accommodate Windows 7  or alternatively optimise for Windows 8.1 or Windows 10 see UEFI BIOS Settings.

Press the ↓ arrow and select your Windows 7/8.1/10 Bootable USB Flash Drive and press [Enter].



Variant B: Legacy Boot

For systems older than 2012 you will have to just use the legacy boot with the MBR partition scheme which will be listed by default. There will be no mention of Legacy or UEFI Boot but the boot option will be legacy.

If you wish to install Windows 8.1 32 Bit (unrecommended) on a 2012 or later system you will need to disable SecureBoot and enable legacy boot options.

Press the ↓ arrow and select your Windows 8.1 Bootable USB Flash Drive or DVD and press [Enter]


Select boot from CD/DVD or from USB respectively.

Press any key when prompted such as “h” when it says Press any Key to boot from CD/DVD.


Launching DISKPART from the Command Prompt

You will get a black screen that says Windows.


Change the Time and Currency format and the Keyboard to your desired country. When ready select next.


Now select Repair your Computer.


The following screens differ slightly for Windows 7 and Windows 8.1.

Windows 8.1/10

Select Troubleshoot.


Select Advanced Options


Select Command Prompt


Proceed to using DISKPART

Windows 7

Windows 7 will search for previous installations.


Once its found one, highlight it and select next:


Alternatively if its not found, select next.


Select Cancel when it looks for a system image:


Select cancel again:

diskpart 5

Select Command Prompt:


Proceed to using DISKPART

Launch of DISKPART from within Windows

The following instructions are different for Windows 7 and Windows 8.1

Windows 8.1/10

Right click the Start Button and Select Command prompt Admin.

Product Activation Removal

The elevated command prompt will then open:

Type in DISKPART and press Enter.

Type in LIST DISK and press Enter.



Windows 7

Select the start button and search for cmd:


You will see cmd listed under programs, right click it and select run as administrator:


The elevated command prompt will then open:

Type in DISKPART and press Enter.

Type in LIST DISK and press Enter.




Type in DISKPART and press [Enter]


Type in LIST DISK and press [Enter]


I only have one Disk listed in this example for simplicity so the only choice for me is to select it. The Bootable USB will also be listed as a Disk and you should be careful not to select this by accident.

For a more complicated configuration there may be multiple disks for example on my XPS 8300.

  • DISK 0 = 119 GB = 128GB Crucial M4-CT128M4SSD2 (SSD Boot Drive)
  • DISK 1 = 931 GB = 1 TB Hitachi HD721010CLA332 (Data HDD 1)
  • DISK 2 = 931 GB = 1 TB Hitachi HD721010CLA332 (Data HDD 2)
  • DISK 3 = 1863 GB = 2 TB SeaGate Expansion Desk USB Device (External Hard Drive)
  • DISK4-DISK7 = Empty Card Reader
  • DISK8 = 3894 MB = 4 GB USB Flash Drive (Windows 8.1 USB Flash Drive)


Type in SELECT DISK X where X is the disk number, in the case of my simple example SELECT DISK 0 and press [Enter]


Type in CLEAN and press [Enter] or CLEAN ALL and press [Enter].

  • CLEAN removes all partitions and assigns them as unallocated and is recommended for a Solid State Drive. This allows for the recreation of partitions but is not a wipe. If you want to wipe for a SSD you will need to use a utility like Magic Parted.
  • CLEAN ALL writes zeroes to the entire drive and is recommended for a Mechanical Hard Drive. This will take some time to carry out as you are not just removing partitions and assigning data as "free space" like in CLEAN but physically overwriting this "free space" to effectively remove all the data from the drive. CLEAN ALL is not recommended for a SSD as data is continuously remapped across the SSD Drives surface and a cleaning algorithm like this doesn't work correctly and may reduce the SSDs lifecycle.

If you are confused by the terms FORMAT and WIPE see here where I give an overview for both a HDD and a SSD.


Close down the command prompt by pressing the [x] at the top right.

Alternatively type in EXIT and press [Enter] to Exit Disk Part. Then type in EXIT and press [Enter] to exit the Command Prompt.



Select turn off your PC


Turn back on the PC and begin your install… See:

17 thoughts on “Use of DiskPart to Clean the HDD/SSD

    1. It'll be hard to recovery your data as you've lost the partition. If you proceed with the install you are likely to lose even more data (if it gets overwritten). You'll need to disconnect the drive and get a USB adapter, then you'll need to run a recovery program such as Recuva on it.

    1. Well it tends to happen when you format the drive… You are after all typing "Format" into the command prompt so think about what your doing!!!

      This guide has even been updated to include a warning about data loss and you still done it.

  1. Well, is this only for MBR or something? Please help Philip. I have done 'CLEAN ALL'. And its been 30 minutes now… Should I close it or something? 🙁

  2. Phillip, if I want to remove all the partitions to reinstall Dell Backup and Recovery, do I need to use Clean or Clean All on N5050 15 Inspiron/win7? I have everything 'as shipped' on it, not sure if it has the SDD or else. thanks

    1. Hi and thanks for this guide, i was having issue installing a Windows 8.1 on a machine that actually never had an Ntfs system file installed on (never used any other Then Linux OS on it) and i coudnt remember the fonction name to call it aka Diskpart :3 , i'd like to mention, in order to improve the information provided and mostly concerning people complaining about loose of data on a 'How-to-erase' hard drive thread.. keuf..keuf..always fun to see people trying thing they dont even understand the purpose but well.. Maybe you should had a line to suggest using this specific order of command that would prevent from accidental loose of data or drive mistake:
      # DISKPART
      # list disk
      # select disk X <<(Where X stand for the drive letter)
      # list volume <<(this will show all volume stored in the selected Drive ie: amovible, or physical as well as the listed name and space use/available)
      # List partition < 100gb | 100gb | 100gb then only format 2/3 of theyse partition would leave an additional 100Gb that windows woudnt writte over.)

      Best regards!

  3. The process work well and after a few minutes, I got a message saying: "Diskpart has encountered an error: The semaphore timeout has expired. See the System Even Log for more information". There's two issues here 1) what is a 'semaphore' and 2) where is located the System even Log?

  4. i did the same thing i hade disk 0 with 1 terabyte and disk 1 (ssd) with 232giga and now i cant see the the ssd is not even bottable eny more plz some 1 help me with thet email

  5. I'm able to select Disk 0, my HD, but when I attempt to "clean" in command prompt, I get this message: "Diskpart has encountered an error: Incorrect function. See the system event log for more information." Any ideas? I came to this thread, because I was unable to format and delete partitions within Windows Setup. Thanks!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.