Wondershare Recoverit

Hard Drive Recovery

  • Recovers deleted or lost files from hard drive effectively, safely and completely.
  • Supports data recovery from 500+ data loss scenarios, including computer crash, partition loss, accidental human error, etc.
  • Supports 1000+ file formats recovery with a high success rate and without any quality loss.
Free Download Free Download Free Download Learn More >
hard drive recovery

How to Format Hard Drive Using DiskPart and Command Prompt?

Wondershare Recoverit Authors

Jan 15, 2024 • Filed to: Answer Hard Drive Problems • Proven solutions

Yesterday I was trying to format the hard drive of my computer using DiskPart. But I am not sure about the detailed steps. Can anyone guide me on how to format using DiskPart?

Hard drive formatting is always crucial, and if not done appropriately, it can even make it non-functional. But performing it with DiskPart or command prompt can save your hard drive from this risk. A formatted drive is almost the same as the new drive because formatting clears all the stored media. This article will guide you through the DiskPart commands and ways of formatting hard drive with DiskPart and Command Prompt.

How to Clean Hard Drive Using DiskPart Quick Format Command?

Before learning the steps for cleaning the drive, let's first understand what does DiskPart clean do? When you use the "clean" command in Diskpart, the utility software will clean the selected disks and information from the hidden sectors. All the stored data gets deleted, and you can't undo it. It is recommended to take a backup first if there is some important data in the drive.

The time taken by the complete process depends on the disk size. To clean the drives follow the following steps:

Step 1 Open Command Prompt

Search command prompt, right-click, and run it as an administrator.

option showing cmd to run as administrator

Step 2 Type diskpart

Type the command as mentioned above and press 'Enter' to launch DiskPart.

cmd showing diskpart command

Step 3 Type "list disk"

The command will list all the drives that are available with the computer. After typing the command, press 'Enter'.

list disk command highlighted

Step 4 Select the Drive by typing select disk *

The * mentioned in the command needs to be replaced with the drive number that requires cleaning. Make sure you put the right number else you will end up cleaning the wrong drive.

disk highlighted that would undergo the cleaning process

Step 5 Type "clean"

The "clean" command will wipe out your required hard drive. Press ''Enter'' after typing it. It will clean up all the files and folders of the drive permanently.

window showing clean command

Step 6 Close the Command Prompt after Successful Completion of Disk Cleaning Once the cleaning process completes, the command prompt will show the message that DiskPart cleaning is successful. Close the window from the button located up in the right corner.

window showing disk cleaning successful

Now you can reinitialize, partition and even format the cleaned drive.


How to Format Hard Drive Using Command Prompts in DiskPart?

While formatting a hard drive, you can clean both storage media- internal as well as external. But before beginning the formatting, you need to complete the cleaning of the drive first. The steps are the same as explained above. Once the disk cleaning is successful; you can continue with the formatting of the drive.

To understand how to format using DiskPart look for detailed steps below:

Step 1 Open the command prompt and run as administrator.

Step 2 Type diskpart and press 'Enter'. It will launch the DiskPart.

Step 3 Type list disk to let the Diskpart list all the drives of the computer.

Step 4 Select the required drive by typing select disk *, here * is the number of the drive that will undergo formatting.

Step 5 Clean the files and folders on the selected drive using the clean command.

window showing highlighted commands that are required for cleaning the drive

Step 6 Type list disk and press 'Enter' to confirm the drive that needs to be formatted is still selected. Here the output that comes out has an asterisk (*) before the selected drive.

Step 7 Create a new partition by typing create partition primary and press 'Enter'.

partition memory created

Step 8 Select the created partition and press 'Enter' after typing the command select partition 1.

Step 9 Type active so that the selected partition comes in an active state. Press 'Enter' after that.

selected partition is active

Step 10 Format the drive with the command format fs=ntfs. Press 'Enter' to begin the process.

window showing format command

Step 11 Assign a letter to the drive, to make it available in the File Explorer and then exit.

Press 'Enter' after typing assign letter=*, type your preferred letter in place of * that you want to assign to the partition.

Then to exit the DiskPart, type exit and 'Enter'.

windows showing highlighted commands

After completing all these steps, the drive is available at File Explorer. You can now start storing files on the drive.


How to Delete Hard Drive Partition Using DiskPart?

Sometimes for better management, you need to create more free space by deleting partitions. You also want to delete them because you don't require them anymore or it has become damaged or corrupted. Follow the listed steps to delete the partition with DiskPart.

Step 1 Launch DiskPart in the command prompt by typing diskpart. Press 'Enter.'

Step 2 Type list disk and then press 'Enter' to list down all the available partitions.

Step 3 Select the disk to delete your required partition. Type select disk *, (*) is the disk number. After typing the command press 'Enter.'

Step 4 Type list partition and then 'Enter' to view all the partitions.

Step 5 Now select the partition to be deleted by typing select partition *, again * here is the number of the partition. 'Enter' after typing the command to execute it.

Step 6 Now delete the partition by typing delete partition and begin the deletion by pressing 'Enter.'

image showing all the commands required for partition deletion

If the dynamic disk is in use, use the delete volume command for the deletion process.


What are the DiskPart commands?

DiskPart is a command-line tool that does disk management with a simple Command Prompt. You can do disk listing, formatting, partitioning, and partition deletion with this tool. Several DiskPart commands are used to execute these functions.

The tool first came in Windows XP, and now it is available on almost all operating systems of Microsoft- Windows 2000, XP, Vista, 7, 8, and 10. Before initiating with Diskpart commands on Command Prompt, it is necessary to make a list and then focus by selecting an object. In this way, DiskPart commands will act on the focused object.

As Diskpart gets loaded on the Command Prompt,which is also known as CMD. The CMD is referred to as a command-line interpreter, available in all operating systems. The program allows you to 'Enter' and execute commands. You will be using the platforms like DiskPart and Command Prompt for disk formatting. It is the process of configuring storage mediums like a flash drive and a hard disk drive. During the formatting process, any of the documents or files that are already saved on the drive gets deleted. Usually, it is done before the installation of the operating system, and many times, it is also required for creating an additional storage space too.

Note!
Your stored data gets erased when you format the drive using CMD. Though it can be retrieved by using the recovery software, taking a backup is still advised.

If you have lost your data through the formation, it is strongly recommend that you use Wondershare Recoverit to regain your data. It allows 100MP free recovery amount. Besides, it can save files and videos from crashed hard drive or computer. Download it through the following link.


DiskPart Format Command Options

DiskPart format command that runs on command prompt is used for formatting internal and external storage mediums of hard drives. The command is available in all Windows operating systems like Windows 10, 8 7, Vista, XP, and other older versions too. You can use it to deal with unlocked files means the files that are not currently in use. However, the syntax for the command differs from one operating system to another.

The format command syntax is as following:

format drive: /* /fs:file-system /r:revision /d /v:label /p:count /?

Here * refers to q, c, x, and l

Now understand the syntax in detail:

You will write here the letter that represents the drive or the partition for which you require formatting.

It represents drive will undergo DiskPart quick format without searching a bad sector.

It will enable compression of folder and file. The option is available only when the drive is being formatted to NTFS (New Technology File System). It is a primary file system that is used in Windows 10, 8, 7, Vista, XP, 2000, and NT operating systems.

If there is the requirement to dismount the drive before formatting, then this command is used in the format.

While formatting with NTFS, the command is used on dedupe-enabled drives that consist of files with size more than 100GB.

You will add the file system to which you want the format the drive. The file systems can be FAT, exFAT, FAT32, UDF, or NTFS

It is used to focus the formatting on a specific UDF version. The options include 1.02, 1.50, 2.00, 2.01, and 2.50. If you don't specify any revision, by default it will take the 2.01 version. When you are using /fs:udf only then you can use /r: command.

When formatting is done with UDF v2.50 only then this command can be used to duplicate metadata.

It is used to specify the volume label. If you have not mentioned it before formatting, the systems will enquire about it after the completion of the process.

It will write zero once to all sectors of the drive. If you specify the count, it will write some random number on the drive, as many times as you mention. The random number writing will start once the zero writing completes.

/p cannot be used with /q.

It is used to show help for the several options of commands.


Closing Words

If your hard drive is causing any trouble, you can now quickly fix it by using DiskPart. Follow the steps explained above to clean and format the disk using DiskPart, and also to delete the hard drive partition. Before performing any of these actions, it is necessary to take a backup of the data. Somehow if you forgot taking backup and lost any of your important files during DiskPart commands execution, don't panic. Use Recoverit Mac Data Recovery software to retrieve your lost data.

Recoverit author

Theo Lucia

chief Editor

Home > Resources > Answer Hard Drive Problems > How to Format Hard Drive Using DiskPart and Command Prompt?