Drives failing due to logical or physical issues is a common sight. Unfortunately, there is no clear way to know when or how a drive might fail. What we can try, however, is to make a corrupt storage drive usable.

This is where DiskPart comes in. Here's how you can use DiskPart to wipe, reformat, and partition a drive ready for use.

What Is DiskPart?

DiskPart is a command-line utility that Microsoft ships with Windows. In other words, DiskPart is built in every Windows machine, so you don’t need to download it separately.

DiskPart allows you to wipe the data of a local or an external drive, reformat the drives into a filesystem of your choice, and make new volumes from an existing block of storage.

Now, because DiskPart is a command-line tool, you need to know some commands to use it.

How to Reformat a Drive Using DiskPart

While physical issues can never be corrected with a software tool, you can resolve logical issues by reformatting.

Reformatting a drive involves wiping the drive clean, deleting all the data you have on the drive, and formatting the drive to a filesystem of your choice. The process is simple but results in an unrecoverable loss of data, so back up your files before proceeding.

1. Open DiskPart and Select a Disk

Open DiskPart by typing diskpart in the Start menu search bar, then selecting the Best Match. This will open up a Command Prompt window with DiskPart already selected.

Once the command-line window is open, type list disk and press enter. You will see the list of all available disks pop up on the screen. You will see the disk's name in the first column, the status in the next column, and the size and the free space in subsequent columns. You can ignore the last two columns as they will be empty if your disk is working properly.

DiskPart displaying list of disks

In the list, find the drive you want to format. You can find the drive by size. If you don’t know the size, remove the drive, run the list disk command again, and note the first column's disk numbers. Reconnect the drive, run the command, and you’ll see a new disk number in the list. This is your drive, so note the number.

Now, choose the drive by typing select disk DISK-NUMBER, replacing DISK-NUMBER with the actual number of the disk that you previously noted from the list.

For instance, if I want to select Disk 2, as shown in the image below, I will type the command as select disk 2. Finally, press enter.

You will see a confirmation message telling you that your storage drive is selected. To verify this, type list disk and press enter. The list of drives that appears will mark the selected drive with an asterisk (*) in front of the drive's number.

DiskPart showing disk numbers

If you want to change the drive, repeat the select command with the number of the disk.

2. Clean and Partition the Drive

Now, before reformatting, make sure that you have backed up your data. After this, type clean and press enter. This will erase all the data from your drive. Once DiskPart has successfully cleaned the drive, you will see a message on the screen.

DiskPart cleaning data from a drive

After cleaning the drive, you are ready to reformat it.

One more thing before you move on to reformatting: you need to partition your drive before you can use it again. After cleaning the drive, your computer will no longer recognize the drive as a storage unit. So, you need to partition it into one or multiple blocks for your computer to recognize the device.

You should also consider partitioning your storage drive into multiple filesystems if you are going to use it with different operating systems. For instance, you can partition a portion of storage as exFat for Windows and another portion as macOS Extended Partition for use with Macs.

Related: The Best Free Windows Partition Manager for Your Needs

But for now, we are only going to partition the drive into one storage block. So, type create partition primary or create part pri and press Enter. This will partition the drive into one block.

Diskpart creating partition

After partitioning, make sure to activate the partition as your computer can only use an active partition. So, type active and press enter. This will make the partition you just made an active partition.

Diskpart activating a disk

3. Format the Drive With a New Filesystem

Finally, you can now reformat the drive.

Input format fs= FILE-SYSTEM label=DRIVE-LABEL quick and press Enter. Make sure to replace FILE-SYSTEM with the filesystem of your choice (such as NTFS, FAT, or exFAT) and LABEL with the name of the drive.

For instance, if you are formatting a removable USB drive to hold music, replace the FILE-SYSTEM with “exfat” and the LABEL with “Music.”

A confirmation message will pop up telling you that the drive has been formatted.

Diskpart formatting disk

Related: Fixes for the "Windows Was Unable to Complete the Format" Error

Assign the New Drive a Letter

The final step of the process is to assign your storage drive a letter. Windows needs these letters to display drives in the file explorer. In most cases, the letters “C,“ “D," and “E” are already in use by internal storage devices. So, choose a different one.

In any case, make sure to assign a letter that is not already in use by your internal drives.

Input assign letter=DRIVE-LETTER, replacing DRIVE-LETTER with “f” and press Enter. You will receive a confirmation message telling you that the letter has been assigned.

DiskPart assigning letter to a disk

Now, verify that you have done everything correctly by typing list volume and press Enter. The drive you just formatted will have an asterisk (*) in front of it, and it will reflect all the properties you specified during the process.

Close the DiskPart command-line utility by typing exit and pressing enter.

Reformatting Only Works for Logical Issues

Unfortunately, we can’t solve every storage issue by reformatting. If your drive repeatedly corrupts or fails to show up after reformatting, this can indicate a hardware failure. And nobody can solve a hardware issue with a software tool.

Unfortunately, that means you will need to spend some money and buy a new drive.