diskpart on windows PC to clean and format hard drives

How to use DiskPart commands to clean and format hard drives?

Loading

Important: Using DiskPart commands will completely erase everything on the hard drive you select. It’s crucial that you correctly choose the exact drive you want to clean and format. I always recommend making a full backup of your system before proceeding.

The “diskpart” command interpreter helps you manage your computer’s drives (disks, partitions, volumes, or virtual hard disks) in Windows 10/8/7 and Server.

Before you can use diskpart commands:

The first thing is to list all disks connected to the computer, making sure the right disk is selected. Then select an object to give it focus. After an object has focus, any diskpart commands that you type will act on that object.

How to Format hard drives with DiskPart commands

1. List the disks on the PC

  • Use the Windows key + X keyboard shortcut to open the Power User menu and select Command Prompt (Admin).
  • Connect the external hard drive or SSD that you want clean and format to your computer.
  • Type “diskpart” and press Enter:
  • Type “list disk” to list all the available drives and press Enter.
  • Take your time and very carefully identify from the output of the previous command to find the drive you want to clean.
  • Use “select disk * ” to select the drive and press Enter.

Remember to change * in the command with the number of the drive you want to clean. If you fail to choose the correct number will erase all the data from the wrong drive.

For example, I have four different drives listed, including Disk 0, which is 30GB. I can quickly determine that it’s the primary system drive because I am trying to clean an 8GB hard drive.

2. Clean the hard drive with DiskPart commands

  • Type “clean” to clean data on the drive and press Enter.
  • Type “list disk” to double-check the drive still selected and press Enter.

If the drive still selected, you will notice an asterisk (*) next to the disk.

3. Initialize a new hard drive with DiskPart command

  • Type “create partition primary” to create a partition and press Enter.
  • Type “convert gpt” to create a partition table and press Enter
  • Type “active” to set the partition active and press Enter active
  1. Type the following command to format the partition using NTFS and to set a label, and press Enter:

4. Format the hard drive with Disk Part command lines

For example, I want to format the newly created partition into the NTFS file system and name the hard drive as WC-Drive.

  • Type in “format FS=NTFS label=WC-Drive quick” and press Enter.

You can change the WC-Drive in the command with the drive name you want to use.

  • Type “assign letter=W” to assign a drive letter so that Windows can access it and press Enter:

You can change W in the command to a letter you want that isn’t in use by another drive on This PC.

  • Type “exit” command to close DiskPart to complete the task.

Again, using this guide, remember to take your time and carefully select the drive you want to repair. If you have multiple external drives connected to your computer, it’s a good idea to temporary disconnect them before proceeding to reduce the chances of erasing the wrong drive.

Keep in mind that while there are many other tools to format a drive, DiskPart is likely to be your best choice when you’re dealing with data corruption, drive inaccurately showing the storage capacity, and other serious problems.

Leave a Reply

Your email address will not be published. Required fields are marked *