Fix Corrupted Hard Drive with DiskPart: Step-by-Step
In this article
DiskPart can fix a corrupted hard drive by cleaning the disk, recreating partitions, and formatting it with a healthy file system. This process erases all data, so back up anything important first. You'll need Windows (7 through 11) and administrator access.
What You'll Need
- A Windows PC with the corrupted drive connected (internal or external via USB).
- Administrator login credentials.
- A backup of any data you want to keep (if the drive is still readable).
- Patience – the process can take minutes to hours depending on drive size and condition.
Step-by-Step
- Back up data if possible. If the drive appears in File Explorer, copy files to another drive. If not, skip this step – you'll lose everything.
- Open Command Prompt as Administrator. Press Windows key, type
cmd, right-click “Command Prompt” and select “Run as administrator”. Click “Yes” on the UAC prompt. - Launch DiskPart. Type
diskpartand press Enter. You'll see a new prompt:DISKPART>. - List all disks. Type
list diskand press Enter. Note the disk number of your corrupted drive (e.g., Disk 1). Be careful – the wrong disk will be wiped. - Select the corrupted drive. Type
select disk X(replace X with the actual number) and press Enter. DiskPart confirms: “Disk X is now the selected disk.” - Clean the drive. Type
cleanand press Enter. This removes all partitions and volume information, making the drive appear as unallocated space. It does not physically erase data, but makes it inaccessible. - Convert to GPT (recommended for modern systems). Type
convert gptand press Enter. If you need legacy BIOS compatibility, useconvert mbrinstead. This step is optional but recommended for UEFI systems. - Create a primary partition. Type
create partition primaryand press Enter. DiskPart creates a partition covering the whole drive. - Select the new partition. Type
select partition 1and press Enter. - Format the partition. Type
format fs=ntfs quickand press Enter. For a slower, more thorough format (which can help with bad sectors), omitquick. NTFS is standard for Windows. If the drive will be used as external storage with Macs, considerexfatinstead. - Assign a drive letter. Type
assignand press Enter. Windows assigns the next available letter. - Exit DiskPart. Type
exitand press Enter, then close Command Prompt. - Check the drive. Open File Explorer – the drive should appear with a letter and be ready to use. Copy a test file to confirm it works.
Common Mistakes
- Selecting the wrong disk. Double-check the disk number in
list disk. A wrong selection wipes the wrong drive. - Skipping the backup. DiskPart's
cleanandformatcommands destroy all data. There is no undo. - Using
clean allunnecessarily.clean allzeroes every sector and takes hours. Use plaincleanunless you need to securely erase. - Formatting with the wrong file system. NTFS works for Windows-only use; exFAT is better for cross-platform external drives.
- Not running as administrator. DiskPart requires admin rights. If you see “Access denied”, close and reopen Command Prompt as admin.
Tips
- Before using DiskPart, try
chkdsk X: /f(replace X with drive letter) – it can fix file system corruption without wiping data. - If the drive is making clicking noises or is not detected at all, DiskPart may not help – it's likely a physical failure. Stop using it to avoid further damage.
- For a large drive (e.g., 2TB+), the quick format is fine for most cases. A full format takes much longer but can detect bad sectors.
- After formatting, run
chkdsk X: /rto scan for bad sectors and attempt recovery – this can take hours but is worth it. - If the drive is external, connect it directly to a USB port (not a hub) to avoid power issues.
Troubleshooting
DiskPart says “Access is denied” or “Insufficient permissions”. Close Command Prompt and reopen it as administrator. Also check that the drive is not write-protected (some SD cards and USB drives have a physical lock switch).
DiskPart hangs at “Clean”. The drive may have bad sectors or a failing controller. Wait 10 minutes; if still stuck, close Command Prompt, disconnect the drive, and try again. If it repeats, the drive is likely physically failing.
Drive is not listed in list disk. Check connections – try a different cable, port, or computer. If it's an internal drive, check BIOS/UEFI to see if it's detected there. If not, it's likely dead.
Format fails with “The volume is too big” or similar. Ensure you selected the correct partition. If the drive is over 2TB and you used MBR, convert to GPT first (step 7).
After formatting, the drive shows as RAW again. This indicates physical damage or failing sectors. Run chkdsk X: /r to attempt repair, but if it reoccurs, replace the drive.
If DiskPart cannot fix it at all. The drive may be beyond software repair. Consider professional data recovery (expensive) or replace the drive. For a system drive that won't boot, try Windows Recovery Environment's Command Prompt instead of the normal one.
Frequently Asked Questions
Will DiskPart fix a physically damaged hard drive?
No. DiskPart only fixes logical corruption (file system, partition table). Physical issues like clicking sounds, motor failure, or bad sectors cannot be repaired by software.
Does DiskPart erase all data?
Yes. The clean command removes all partitions and the format command overwrites the file system. Data is unrecoverable without specialized tools. Always back up first.
Can I use DiskPart on an SSD?
Yes, the steps are the same. However, SSDs rarely have logical corruption – if an SSD fails, it's usually a controller issue that DiskPart can't fix.
What is the difference between clean and clean all?
clean removes partition and volume information quickly. clean all overwrites every sector with zeros, which takes hours and makes data recovery impossible. Use clean for normal fixes.
Can I recover data after using DiskPart clean?
Possibly, with professional recovery software or services, but not guaranteed. The data is not physically erased, but the file system structure is gone. Act quickly and stop using the drive to improve chances.
Is DiskPart safe for a drive with bad sectors?
It can be, but it won't repair bad sectors. Formatting may mark them as unusable, but if the drive has many bad sectors, it's likely failing and should be replaced.