Skip to main content

How to use DiskPart to clean and format drive not working on Windows 10

Windows 10 fix hard drive with DiskPart
Windows 10 fix hard drive with DiskPart (Image credit: Windows Central)

On Windows 10, when an external drive (USB flash drive, SD card, or secondary drive) stops working due to data corruption or another logical problem, you can use the DiskPart tool to erase everything and start with a new partition.

DiskPart is a command-line tool designed to manage drives, partitions, volumes, and virtual disks using Command Prompt, which usually works better than other Windows 10 tools, such as Disk Management and the Format feature available in File Explorer.

It's worth noting that you can have different types of partition styles, including Master Boot Record (MBR) and GUID Partition Table (GPT). The MBR is the legacy partition style for the standard Basic Input/Output System (BIOS). The GPT is a newer partition style usually found in Unified Extensible Firmware Interface (UEFI) devices. The difference between the two is that GPT is meant to replace MBR since it supports more than four partitions on a drive, and it's required on drives with more than 2TB of storage. You usually would want to use GPT, but MBR is also acceptable for external drives. These instructions will help you use DiskPart on either partition style.

Also, these instructions will erase everything on the selected drive, and you cannot undo the changes. If the drive is still accessible, it's recommended to back up the data before proceeding. If you have multiple drives connected to your device, it's recommended to disconnect them to avoid selecting the wrong device.

In this Windows 10 guide, we will walk you through the steps to use the DiskPart tool to clean and format a hard drive to fix data corruption and other problems.

How to fix drive (MBR) problems with DiskPart on Windows 10

To use DiskPart to fix storage drive issues on Windows 10, use these steps:

  1. Open Start.
  2. Search for Command Prompt, right-click the top result, and select the Run as administrator option.
  3. Type the following command to launch DiskPart and press Enter:diskpart
  4. Type the following command to list all the active drives and press Enter:list disk
  5. Type the following command to select the drive to clean and press Enter:select disk DISK-NUMBERIn the command, replace DISK-NUMBER with the drive number you want to repair as it appears in the "Disk" column. If you do not perform this step correctly, you could erase the wrong drive. Proceed with caution.
  6. Type the following command to wipe out the drive and press Enter:clean

Source: Windows Central (Image credit: Source: Windows Central)
  1. Type the following command to confirm the drive is still selected and press Enter:list diskQuick note: The output should include an asterisk (*) next to the selected drive. If the correct storage is not specified, perform step 5 again.
  2. (Optional) Type the following command to convert the drive to an MBR partition style and press Enter:convert mbrQuick note: This step is only required if the drive is currently set GPT, and you must use MBR partition style. If the partition is already MBR, you don't need to run the command, but running the command won't affect the process. You should be able to determine the partition type with the list disk command. If the drive doesn't have a GPT mark (*), it's an MBR partition.
  3. Type the following command to create a new partition and press Enter:`create partition primary
  4. Type the following command to select the new primary partition and press Enter:select partition 1
  5. Type the following command to make the partition active and press Enter:activeQuick tip: You only need to set a partition as active when using the MBR (Master Boot Record) partition style. You can determine if the drive uses an MBR or GPT partition style with the list disk command. If the partition has a mark in the GPT column, it's not an MBR partition. If you need to set up a GPT partition style, use the other steps (see below).

Source: Windows Central (Image credit: Source: Windows Central)
  1. Type the following command to format the partition using the NTFS file system, set a drive label, and press Enter:format fs=FILE-SYSTEM label=DRIVE-LABEL quickIn the command, replace FILE-SYSTEM with the name of the file system you want to use, such as NTFS or FAT32, and replace DRIVE-LABEL with the name of the drive as you want it to appear in File Explorer. The quick option is optional to perform a format more quickly. However, if you are not sure about the drive's condition, it is best to skip the option. Remember that depending on the hard drive's size, the format could take a long time.This example formats the drive using the NTFS file system and names the partition "myData":format fs=ntfs label=myData quick

Source: Windows Central (Image credit: Source: Windows Central)
  1. Type the following command to assign a letter and make the drive available in File Explorer, and press Enter (as needed):assign letter=DRIVE-LETTERIn the command, change DRIVE-LETTER for the letter you want the drive to use, which is not assigned to another device.This example assigns the "G" letter:assign letter=g
  2. Type the following command to terminate DiskPart and press Enter:exit
  3. Type the following command to close Command Prompt and press Enter:exit

Once you complete the steps, if the drive does not have physical issues, it should now be available through File Explorer, and you can begin to store files on it.

If you determine that the external storage has an issue related to hardware and you need a replacement, we recommend the Western Digital My Passport because it offers up to 5TB of reliable storage, and it has a compact design at a reasonable price.

How to fix drive (GPT) problems with DiskPart on Windows 10

To use DiskPart to fix drive issues with GPT partition style, use these steps:

  1. Open Start.
  2. Search for Command Prompt, right-click the top result, and select the Run as administrator option.
  3. Type the following command to run DiskPart and press Enter:diskpart
  4. Type the following command to list all the active drives and press Enter:list disk
  5. Type the following command to select the drive that you want to clean and press Enter:select disk DISK-NUMBERIn the command, replace DISK-NUMBER with the drive number you want to repair as it appears in the "Disk" column.
  6. Type the following command to wipe out the drive and press Enter:clean

Source: Windows Central (Image credit: Source: Windows Central)
  1. Type the following command to confirm the drive is still selected and press Enter:lisk diskQuick note: The output should include an asterisk (*) next to the selected drive. If the correct storage is not specified, perform step 5 again.
  2. Type the following command to convert the partition style to GPT and press Enter:convert gpt
  3. Type the following command to create a new partition and press Enter:create partition primary
  4. Type the following command to select the new primary partition and press Enter:select partition 1

Source: Windows Central (Image credit: Source: Windows Central)
  1. Type the following command to format the partition using the NTFS file system, set a drive label, and press Enter:format fs=FILE-SYSTEM label=DRIVE-LABEL quickIn the command, replace FILE-SYSTEM with the name of the file system you want to use, such as NTFS or FAT32, and replace DRIVE-LABEL with the name of the drive as you want it to appear in File Explorer. The quick option is optional to perform a format more quickly. However, if you are not sure about the drive's condition, it is best to skip the option. Remember that depending on the hard drive's size, the format could take a long time.This example formats the drive using the NTFS file system and names the partition "myData":format fs=ntfs label=myData quick

Source: Windows Central (Image credit: Source: Windows Central)
  1. Type the following command to assign a letter and make the drive available in File Explorer, and press Enter:assign letter=DRIVE-LETTERIn the command, change DRIVE-LETTER for the letter you want the drive to use, which is not assigned to another device.This example assigns the "W" letter:assign letter=w
  2. Type the following command to terminate DiskPart and press Enter:exit
  3. Type the following command to close Command Prompt and press Enter:exit

After you complete the steps, the drive should be fixed with a GPT partition style and accessible from File Explorer.

More Windows resources

For more helpful articles, coverage, and answers to common questions about Windows 10 and Windows 11, visit the following resources:

Mauro Huculak is technical writer for WindowsCentral.com. His primary focus is to write comprehensive how-tos to help users get the most out of Windows 10 and its many related technologies. He has an IT background with professional certifications from Microsoft, Cisco, and CompTIA, and he's a recognized member of the Microsoft MVP community.

30 Comments
  • Currently doing that, receives a notification about that article...
  • Dear readers. Please be VERY careful using DiskPart. One even slightly wrong move and you can turn an otherwise good day into a disaster.
  • You have backups... right?
  • LOL, well, that's entirely my point. One wrong command and you can blow away your backup disk. Or the disk with all of your data. Or... [fill in your favorite whole disk loss scenario here] And speaking of backups... unless you know how to use your backups to get yourself back up and running, you might as well not take backups. The most important aspect of backups is recovery... and making sure that you test your recovery plan regularly. Posted from Windows Central for Windows 10
  • Also note that diskpart clean is not the same as secure erase. Data can be recovered. Backups also need to be considered from a security standpoint. Backups are grand, but you need to consider security at every point in your data usage. If you do not fully understand what you are doing then do not put any sensitive data into the system concerned. Especially if that data is owned by someone else. You need to consider your legal responsibilities at every turn, especially on a home PC that has a general purpose use. Be careful, friends. Better to lose the data entirely than have a backup compromised. The most important aspect of backups is NOT recovery, it is security. You will see many people say that diskpart clean is like restoring to a factory fresh drive state. They are either misguided or attempting to mislead you. Be aware.
  • To help users, we should mention:
    To securely erase a disk with diskpart use [clean all] this writes zeros to the entire drive and is reasonably secure Windows also provides other more through secure erase mechanisms, like additional random passes when using [format /p:3] and there is also [ciper] for more granular secure erasure. Use docs.microsoft.com for a complete reference on how to use any of these commands.
  • But anything important should be backed up on an external drive and unplugged from the machine.
    even use cloud storage if you must.
  • any help to recover my disk
  • Isn't Windows + I the settings app? I've used Windows + X for power user menu after learning about it on this site.
  • Correct... Win+I is settings, Win+X is the power user menu. Posted from Windows Central for Windows 10
  • For the few protected SD cards that can't be formatted using this method, you can try using an older camera to format the media.
  • Thanks for the clear directions. I've had to toss some of my external backup drives because they were just to unruly to rely on or use.
  • Small tip for the lazy fingers: you can abbreviate diskpart commands using the first 3 letters of each word. Example: "list disk" can be entered as "lis dis", as well as "select partition 1" can be shortened to "sel par 1"
  • Ugh. I save command line for my Linux boxes. Disk Management FTW! Posted via the Windows Central App for Android
  • Disk Management is a great utility, but it's not nearly as powerful as diskpart. It's great for basic to intermediate disk and volume tasks, but for anything else it begins to show its limits. For example, Diskpart has full control over partitions that Disk Management intentionally ignores - MSR and OEM reserved partitions for example, allowing you to mount and browse them if you like. This means an advanced user can update the recovery image on an OEM machine manually so that factory restores have patches integrated, or less junk. Additionally, Disk Management will not clean a drive - you can delete all partitions off a drive, rendering it empty of data, but you cannot delete the actual partition table - the table will simply have no entries. "clean" sets the drive back to being uninitialised, like brand new. 
  • Uninitialized yes, but NOT like brand new. For that you need to use a secure erase process. Be aware that data can be recovered after a diskpart clean. It is not a secure process.
  • Can't wait to go home and try this. I've got a Lexar 128Gb micro SD that became corrupted thanks to an Insider build on my Lumia 650.
  • Those keen to use Microsoft e-drive compatible opal hardware encryption via Bitlocker (and usually via a TPM), especially for the boot drive, this is an essential process. Otherwise software BitLocker is often used instead, as Windows only engages hardware BitLocker on a drive that was uninitialized at Windows install (you will want to do a clean install). Crucial and Samsung SSD drives support this as do some Seagate HDDs and hybrid drives. I use a fully encrypted desktop PC using hardware encryption for SSD (Crucial MX100 512Gig) and HDD (3TB Seagate). Diskpart is an essential part of getting this setup working properly. I need this due to my trade union activity and my desire to use it as a gaming PC too. Please note that encryption is a bit of an art and that you will want to be very good at making sure there are no weak links in your data handling, way beyond a post here. This encrypts data at rest only, but is great for a multi use home PC to avoid data burglary risk for a home desktop, as part of a full encryption regime. Make sure your backups are also encrypted and that you employ good file level encryption on data that moves outside of your main box (be careful with NAS and cloud storage). Watch your backs, folks.
  • I find it interesting that so much stress is given to be careful during this process but that there are so many grammatic and other errors in the article. How can I trust that any of the information won't leave my HDD unusable? Come on, someone perform a cursory proofing.
  • This came in handy when I had a USB Stick set up to run FreeNAS. When I tried to use the Stick for other stuff I noticed the majority of the space gone and couldn't get it back by simply formatting it.
  • Tried this, didn't work. I think my SD card is just entirely ******
  • I have a micro SD SanDisk class10, 64GB In my lumia W10 650, keeps showing error phone scans but nothing fixes, would it if I put SD CARD ON LAPTOP,
  • It wont even if you put it in a laptop.
  • Yeah, tried that on my 13-month-old Surface Pro 2017. Doesn't do squat if the SSD has failed. And, being 13 months old, it wasn't under warranty, to which Microsoft said (paraphrasing) "sucks to be you".
  • Love diskpart! I always use the "clean" command to wipe out my backup drives right before making another clone to them. It's sometimes the only way to get rid of those pesky hidden or "System Reserved" partitions and definitely great for bloatware laden external drives too.
  • It stands to reason that...
    There is no fundamental difference between what you can do in Computer management and Command prompt.
    Disk management is really the interface of Diskpart.
    If Disk management cannot recover a drive, then neither can Diskpart
  • Hello,
    Thank you for your clear tutorials!
    Before formating my unacessible hard drive to avoid any data loss, I was hoping to try out this other turorial on your website:
    how-troubleshoot-and-fix-external-drives-when-not-detected-windows-10 Is there any chance to go through the steps of "Fixing drive not initialized" WITHOUT choosing the "format" option on step 7 and rather choose not to format it? Is it really just at this step that the process will impact the data? I would like to give it a try, hoping to find out that it's only an MBR issue that can be fixed (software like EaseUS Partition Master didn't help so far). Thank you in advance for your reply.
  • Thank you a couple other websites were a little out of date or missing a step that I didn't know enough to fill in for myself
  • You could have said that a simple "format fs=FILE-SYSTEM label=DRIVE-LABEL quick" will take a while, depending on the size of the drive you want to do it to. I have a 2TB drive currently being formatted. It is at 62% after close to 1 hour. G e e, t h a t' s n o t t h a t q u i c k !
  • Diskpart, that brings back memories when I first came to the Pc/windows world, in 1997. I had my computer a few weeks and the drive went belly up so the company I got it from sent me a new one, I had no idea what I was doing, had to get a mate to help me to set it up and install windows. Far different to the Amiga I had at the time.