How to repair USB external hard drive with DiskPart

If you are reading this post, it is because you want to know how to repair your external hard drive . Sometimes it happens that we have been using external USB hard drives, pen drives, SD cards and other types of external storage units for a long time without any problem and, when you least expect it, they stop working.

We tend to think that to repair an external hard drive you have to open it and be a handyman, or directly go to a technician or throw it away, but the truth is that there are many ways to repair USB drives or memories without too many complications or advanced knowledge .

Keep reading, it’s not time to throw in the towel yet

When a disk stops working, the most common thing is that the disk partition has been corrupted and damaged for some reason (remove it without security, for example; you do it twenty times and nothing happens, but at twenty-one you kill it) , so Windows can’t read it.

repair an external hard drive

In any case, it never hurts to rule out other possibilities, for example that the USB cable or port does not work correctly , so I recommend that you try it with a different cable in the same port, or in another different port with the same cable.

Another more viable option would be to try other devices , or the same one on another computer. That should be enough.

DiskPart, advanced disk management and administration

If you have already ruled out any technical failure, it is time to get down to work with the tool that will solve your problem in most cases . I’m talking about DiskPart , a more flexible disk management tool than the operating system’s own drive formatting utility or Disk Manager.

In fact, we could say that Disk Management is the graphical version of DiskPart, with the difference that DiskPart is more complete and advanced, allowing you to do certain things that Windows Disk Management does not .

What is DISKPART used for?

With DiskPart we can manage partitions , that is, create them, delete them, even edit them, assign or change disk letters, convert basic disks to dynamic disks and vice versa, use the  clean  command to erase all information, or remove write protection , among other things.

Some interesting uses that we can give to this utility are:

It should be noted that DiskPart is a very powerful tool and by performing the following process you will completely erase the selected device , making it impossible to reverse the changes, so it is very, very important that you are sure that the selected drive is the right one .

All (most useful) DiskPart commands

Like any command line tool, DiskPart has a series of commands and parameters that we can use for different purposes.

Here is a list of the most useful commands and what each of them is for, including the ones we will use in this guide to repair an external hard drive.

list disk/volumeGet a list of all available disks or volumes.
list partitionGet a list of all partitions on the selected disk.
select disk/partition/volumeSelect a disk, partition or volume.
detail disk/partition/volumeView the details of the selected disk, partition, or volume, such as its properties or the list of volumes.
create partition primary/logical size=#Create a primary or logical partition, where # is the size in MB.
delete disk/partition/volumeDelete the selected disk, partition or volume.
create volume stripeCreates a volume with two or more specified dynamic disks.
convert basic/dynamic/mbr/gptConvert a disk from dynamic to basic, basic to dynamic, GPT to MBR, or MBR to GPT.
extendExtend the selected partition or volume.
assignChange the letter associated with the selected volume.
cleanClean all settings on the selected disk.
activateMark a selected partition as active.
formatFormat a volume or partition.
exitQuit DiskPart.
helpView a list of available commands in DiskPart.
help commandShows detailed help on the operation of a specific command.

Wiping and formatting a disk with DiskPart

  1. First of all we need to run the DiskPart utility. Open the Run window by pressing the Windows + R keys , type diskpart and press the ENTER key or click OK .

  2. Insert the list disk command  to display a list of all available drives.

    list disk command in diskpart
  3. Now take your time to identify the corresponding disk, paying attention, above all, to its size. When you think you have it, use the command  select disk n  to select it, while  n is the number of your disk.
  4. Confirm that you have selected the correct disk with the  detail disk command .

    See details of a disk on your pc
  5. Type the clean command  to clean the disk’s partition table (this is irreversible, so again, you can go back to the previous step to make sure the selected disk is the right one ).
  6. When the process is complete, run the create partition primary command  to create a new primary partition. If the operation was successful, enter the active command  to activate it.
  7. In order for the partition we just created to be easily accessible from Windows, we need to format it. In this case, we will execute the format fs=fat32 quick command if it is a USB stick or an SD card, or the format fs=NTFS quick command if it is a hard drive. We can also add label=NAME  to the previous command  to customize the device label, while  NAME  is the name, forgive the redundancy, that you want to give to the disk.
  8. Also, we will assign a letter to the drive with the assign command. In this way, it will be the operating system itself that decides the letter that is assigned to it. If you want to choose it yourself, you can specify it with  assign letter=A .
  9. Lastly, enter the  exit command to end the whole process and close the utility, and close the Command Prompt window as well.


Keep in mind that while there are plenty of third-party apps out there to format a drive, DiskPart is probably always your best bet when:

  1. The file system has been corrupted
  2. Your operating system does not detect the disk
  3. The disk is shown with a size of 0 bytes

With that being said, I hope you have understood what DiskPart is and how you can use it to fix an external hard drive or pen drive that is failing in some way.