Fix a Corrupted Hard Drive Using CMD

Christina
Written byChristinaUpdated on May 23, 2025
Gerhard Chou
Approved byGerhard Chou

Table of Contents

Tip: Before fixing the corrupted hard drive using CMD, you can use data recovery software to export/recover all data from the corrupted hard drive and save the data to another drive. This data recovery tool also offers disk management tool for disk repair or disk reformatting.

PAGE CONTENT:

Hard drive corruption can strike at the worst possible times - just when you need to access critical files or transfer data. While many users assume that a corrupted drive is permanently damaged, that's not always the case. Sometimes, software-level errors cause the issue, and you can often fix these using tools built right into your Windows operating system. One of the most effective methods is using Command Prompt (CMD).

In this article, we will guide you through how to fix a corrupted hard drive using CMD commands like CHKDSK, SFC, and DISM. We'll also explore some preventive measures and provide guidance on when to back up data or recover files before proceeding.

fix corrupted hard drive using CMD

What Is a Corrupted Hard Drive?

A corrupted hard drive is one that has developed errors in its file system or storage structure, making it difficult or impossible to access data normally. Symptoms of a corrupted drive include:

  • The drive not appearing in File Explorer
  • Windows asking you to format the drive before use
  • Slow read/write performance
  • Errors like "Location is not available" or "The file or directory is corrupted and unreadable"

Corruption can occur in both internal and external drives and can be caused by various factors ranging from physical damage to software conflicts.

Common Causes of Hard Drive Corruption

Understanding the cause helps you prevent future issues. Here are some typical reasons why hard drives become corrupted:

  1. Sudden Power Failures: If your PC shuts down abruptly while writing data, it may leave the file system in an inconsistent state.
  2. Improper Ejection of External Drives: Pulling out a USB or external drive without safely removing it can corrupt data structures.
  3. Malware or Virus Infections: Some malicious programs target storage devices, leading to data corruption.
  4. Bad Sectors: Physical damage or aging may create unreadable areas on the disk.
  5. System Crashes or Software Errors: Faulty software or OS crashes can leave drives with incomplete file operations.

Preliminary Checks Before Using CMD

Before diving into CMD commands, perform these basic checks:

1. Ensure the Drive Is Properly Connected

Verify that the drive is securely plugged in, especially for external drives. Try another port or system to rule out connectivity issues.

2. Check if the Drive Appears in File Explorer

If it's missing, go to Disk Management:

  • Choose Disk Management by pressing Win + X.
  • Look for the drive and note its Drive Letter and File System Status

3. Assign a Drive Letter (if missing)

Right-click the volume and choose "Change Drive Letter and Paths" to assign one.

Assign a Drive Letter (if missing)

Once the drive is recognized and a letter is assigned, you're ready to use CMD.

Recover Data Before Fixing the Corrupted Hard Drive

Before launching Command Prompt to fix the corrupted hard drive, you can use data recovery program - such as Donemax Data Recovery to recover inaccessible or lost files from the drive. Then save the files to a good drive or external storage device.

Step 1. Click Download button below to download Donemax Data Recovery and install it on your computer.

Step 2. Open Donemax Data Recovery and select the corrupted hard drive to start data recovery.

select the corrupted hard drive to start data recovery

Step 3. Click on Scan button to deeply scan the corrupted hard drive and find all recoverable files including existing files, inaccessible files, deleted/formatted/lost files, etc.

scan the corrupted hard drive and find all recoverable files

Step 4. When the scan gets finished, it lists all recoverable files. Then select the wanted files, click on Recover button to save them.

click on Recover button to save the wanted files

Donemax Data Recovery also can help you repair the corrupted hard drive. Just choose Disk Manager, then select the corrupted hard drive, click Repair.

repair the corrupted hard drive

Use CHKDSK Command to Fix the Corrupted Drive

One of the most effective built-in tools for fixing a corrupted hard drive in Windows is CHKDSK, short for Check Disk. It is designed to identify and correct logical file system errors, scan the disk for bad sectors, and recover readable data from damaged parts of the drive.

1. What Is CHKDSK and Why Use It?

CHKDSK is a command-line utility that checks the integrity of file systems (like NTFS and FAT32) and helps repair logical inconsistencies. If your hard drive is behaving erratically, showing missing files, or reporting access errors, CHKDSK is usually the first utility to try.

Here's what CHKDSK can do:

  • Repair file system structures and metadata
  • Recover readable data from bad sectors
  • Free up space by removing orphaned entries (e.g., from deleted files)
  • Reestablish lost connections between directories and files

It's worth noting that CHKDSK doesn't fix physical hardware failures but can often stabilize a disk enough to allow data recovery.

2. Understanding CHKDSK Parameters

Before using CHKDSK, it helps to understand its command-line switches:

  • /f: Fixes any detected file system errors.
  • /r: finds corrupt disk sectors and retrieves information that can be read. This includes /f automatically.
  • /x: If required, compels the driving to dismount first. It ensures exclusive access to the volume.
  • /scan: On newer Windows versions, performs an online scan (without unmounting).
  • /spotfix: Fixes issues found by /scan on the next reboot.

3. How to Run CHKDSK via Command Prompt?

Follow these steps:

Step 1: Open Command Prompt as Administrator

Select Run as Administrator by right-clicking Command Prompt after typing cmd into the Start Menu.

Open Command Prompt as Administrator

Step 2: Identify the Correct Drive Letter

In File Explorer or Disk Management, locate the drive letter assigned to the corrupted drive (e.g., E: or F:)

Step 3: Run the CHKDSK Command

Use this format:

chkdsk X: /f /r /x

  • Replace X: with the actual drive letter

    Example:

    chkdsk E: /f /r /x

    Run the CHKDSK Command

Step 4: Let It Complete

  • CHKDSK will go through multiple stages: checking file system, verifying indexes, security descriptors, file data, and free space.
  • Depending on the size of the drive and the degree of contamination, it could take a few minutes to several hours.

4. Example Output and Interpretation

After running CHKDSK, you'll see messages like:

  • "Windows has scanned the file system and found no problems." – No issues found
  • "Windows replaced bad clusters in file..." – Recoverable bad sectors were fixed
  • "An unspecified error occurred." – Indicates serious corruption or possible hardware issues

Keep a note of how many KB in bad sectors were found - too many may signal that your drive is physically failing.

5. What If CHKDSK Can't Run?

Sometimes, CHKDSK will refuse to run because the volume is in use. In that case, it may prompt:

"Would you like to schedule this volume to be checked the next time the system restarts? (Y/N)"

Type Y and press Enter. Then restart your computer to allow CHKDSK to run before Windows boots. This is often necessary for checking your system (C:) drive.

6. CHKDSK Log Report (Optional Advanced Step)

To review a CHKDSK log after it runs:

  1. Open Event Viewer (eventvwr.msc)
  2. Go to Application in Windows Logs.
  3. Look for Wininit as the source
  4. Click the entry to see detailed results of the last CHKDSK operation

This is helpful if the output was too long to read in CMD or you want to keep a record.

7. Limitations and When to Use Alternatives

While CHKDSK is powerful, it has its limits:

  • It cannot fix physical damage (e.g., a scratched platter or worn-out NAND cells)
  • It may not repair drives with severely corrupted partition tables or boot sectors
  • It may delete corrupted files if recovery is not possible

If CHKDSK fails to complete or repeatedly reports errors, consider switching to tools like Donemax Data Recovery, TestDisk, DiskGenius, or contact a professional recovery service.

8. Use SFC and DISM to Repair System File Corruption

If your system files are also affected or CHKDSK didn't resolve the issue, you can run SFC and DISM to fix system-level corruption.

A. Use SFC (System File Checker)

SFC scans for and repairs corrupted Windows system files.

Steps:

  1. Open CMD as Administrator
  2. Run:

    sfc /scannow

    Use SFC (System File Checker)

    The process may take up to 30 minutes. If errors are found and fixed, restart your computer and try accessing the drive again.

B. Use DISM.

DISM repairs the Windows image, which can be essential if SFC cannot fix issues.

Command:

DISM /Online /Cleanup-Image /RestoreHealth

Use DISM

Once completed, rerun sfc /scannow to ensure all issues are fixed.

9. Use DiskPart to Check or Clean the Drive

DiskPart is a command-line tool for disk management. Use it with caution—some operations like clean will wipe the drive.

A. How to Open DiskPart

  1. Type diskpart in CMD and hit Enter
  2. Run:

    list disk
    select disk X

    • Replace X with the disk number
    • Identify the affected volume

B. To Clean and Reformat (Data Will Be Lost)

If the drive is beyond repair but still detected, you may need to clean and reformat:

clean
create partition primary
format fs=ntfs quick
assign
Exit

To Clean and Reformat

⚠️Note: This will erase all data. Only do this if you're certain there's no critical data left or if you've recovered it already.

10. Format the Corrupted Drive via CMD (Last Resort)

When recovery isn't possible, formatting can help reuse the drive.

Command:

format X: /fs:ntfs

Format the Corrupted Drive via CMD

  • Replace X: with your drive letter
  • Use /fs:exfat or /fs:fat32 for compatibility with other systems

This will erase the existing file system and recreate a clean one. If successful, the drive should be accessible again.

Preventive Tips to Avoid Future Hard Drive Corruption

Once your drive is repaired or replaced, follow these best practices to prevent corruption in the future:

1. Always Safely Eject External Drives

Improper ejection is a leading cause of corruption. Use the "Safely Remove Hardware" feature.

2. Keep a Regular Backup

Use external drives or cloud services to back up data regularly.

3. Use Reliable Antivirus Software

Keep your PC secure from malware that could corrupt files or drive structures.

4. Install a UPS for Desktops

A UPS (Uninterruptible Power Supply) can protect against power failures during important tasks.

5. Run CHKDSK Regularly

Periodic CHKDSK checks can identify issues early before they become critical.

6. Update Your Operating System and Drivers

Ensure Windows and device drivers are always updated for stability and performance improvements.

Conclusion

A corrupted hard drive doesn't necessarily mean all is lost. With the right use of Command Prompt tools, you can often fix the drive and restore access to your data. Begin with CHKDSK to fix file system issues, use SFC and DISM for system repairs, and turn to DiskPart or formatting only as a last resort. Remember to back up your data before running any commands that could erase or reformat the drive.

Finally, incorporate preventive measures into your workflow to reduce the risk of corruption in the future. CMD is a powerful tool - use it carefully, and it can help you recover from many common hard drive issues without the need for third-party software.

logo stage

Donemax Data Recovery

Donemax Data Recovery is one of the best data recovery software. It is easy-to-use and can help in recovering deleted, formatted, inaccessible or lost data from HDD/SSD, external disk, USB drive, SD card, camera or other storage devices.

Christina
Contributing Writer

Christina

Christina is the senior editor of Donemax software who has worked in the company for 4+ years. She mainly writes the guides and solutions about data erasure, data transferring, data recovery and disk cloning to help users get the most out of their Windows and Mac. She likes to travel, enjoy country music and play games in her spare time.

Gerhard Chou
Editor in chief

Gerhard Chou

In order to effectively solve the problems for our customers, every article and troubleshooting solution published on our website has been strictly tested and practiced. Our editors love researching and using computers and testing software, and are willing to help computer users with their problems

Hot Donemax Products

DMclone

Donemax Disk Clone

Clone hard drive with advanced clone technology or create bootable clone for Windows/Mac OS.

Donemax Data Recovery

Donemax Data Recovery

Completely and easily recover deleted, formatted, hidden or lost files from hard drive and external storage device.

Donemax Data Eraser

Donemax Data Eraser

Certified data erasure software - permanently erase data before selling or donating your disk or any digital device.