CHKDSK - CMD


Overview

CHKDSK (Check Disk) is a command-line utility in Windows that checks the file system and file system metadata of a volume for logical and physical errors. It is used primarily to scan and repair different types of file system errors, recover readable information from bad sectors, and maintain system performance and integrity. This tool is crucial for troubleshooting disk errors, especially after system crashes and power failures.

Syntax

The basic syntax of the CHKDSK command is as follows:

CHKDSK [volume[[path]filename]]] [/F] [/V] [/R] [/X] [/I] [/C] [/L[:size]] [/B] [/scan] [/spotfix]
  • volume specifies the drive letter (followed by a colon), mount point, or volume name.
  • filename specifies the files to check for fragmentation (used only with /F).

Parameters:

  • /F Fixes errors on the disk.
  • /V Displays the path of every file on the disk.
  • /R Locates bad sectors and recovers readable information (implies /F).
  • /X Forces the volume to dismount first if necessary (implies /F).
  • /I Performs a lighter check of index entries.
  • /C Skips the checking of cycles within the folder structure.
  • /L:size Changes size of the log file.
  • /B Re-evaluates bad clusters on the volume (implies /R).
  • /scan Runs an online scan on the volume.
  • /spotfix Runs spot fixing on the volume.

Options/Flags

  • /F: Corrects disk errors. It is essential when the integrity of the file system is in doubt.
  • /R: This intensive option finds bad sectors and recovers readable data, consuming more time to execute.
  • /X: Useful when CHKDSK cannot gain exclusive access to a disk with ongoing processes.
  • /I and /C: Safeguards for reducing the amount of time taken for checking NTFS volumes by skipping certain checks.
  • /scan and /spotfix: For newer Windows versions, these provide fast scanning and fixing options without full volume lockdown.

Examples

  • Basic Usage: Scan disk E without fixing errors:
    CHKDSK E:
    
  • Fix Errors on Disk E: Also repairs the volume:
    CHKDSK E: /F
    
  • Recover Data: Locate bad sectors and recover data:
    CHKDSK E: /R
    
  • Force Dismount and Fix: Useful when CHKDSK cannot obtain exclusive use of the drive:
    CHKDSK E: /X /F
    

Common Issues

  • Access Denied: Ensure you run CMD as an administrator to avoid permission issues.
  • CHKDSK Hangs: This can happen if there are severe errors; a reboot may be necessary.
  • No Errors Fixed After Scanning: Ensure all parameters like /F or /R are correctly used based on the desired operation.

Integration

Integrate CHKDSK with other tools for system maintenance:

schtasks /create /sc weekly /tn "Weekly Disk Check" /tr "chkdsk C: /R /F" /st 02:00

This script schedules a weekly task to check and fix disk errors in volume C.

  • DISKPART: A more powerful tool for disk partitioning and management.
  • SFC (System File Checker): Scans and repairs system files, often used in conjunction with CHKDSK.

Further Reading: