chkdsk.exe

Check Disk - check and repair disk problems

Syntax
      CHKDSK [drive:][[path]filename] [/F] [/V] [/R] [/L[:size]] 

Key
   [drive:]   The drive to check. Drive letter followed by a colon, mount point or volume name.
   
   filename   File(s) to check for fragmentation (FAT only). 
   
   /F         Automatically Fix file system errors on the disk.

   /X         Fix file system errors on the disk, Implies /F
              dismounts the volume first, closing all open file handles.
   
   /R         Scan for and attempt Recovery of bad sectors.
 
   /B         NTFS only: Re-evaluate bad clusters on the volume. Implies /R  ** Windows10+

   /V         Display the full path and name of every file on the disk. 
   
   /L:size    NTFS only: change the log file size to the specified number of kilobytes. 
If size is not specified, displays the current log size and the drive type (FAT or NTFS). /C NTFS only: Skip directory corruption checks. /I NTFS only: Skip corruption checks that compare directory entries to the file record segment (FRS) in the volume's master file table (MFT) /scan NTFS only: Run an online scan on the volume. /forceOfflineFix NTFS only: Must be used with /scan Bypass all online repair; all defects found are queued for offline repair i.e. chkdsk /spotfix /perf NTFS only: Must be used with /scan Uses more system resources to complete a scan as fast as possible. This may have a negative impact on other running tasks. /spotfix NTFS only: Run spot fixing on the volume. /sdCleanup NTFS only: Garbage collect unneeded security descriptor data, implies /F /offlineScanandFix Run an offline scan and fix on the volume. /freeOrphanedChains FAT/FAT32/exFAT only: Free any orphaned cluster chains instead of recovering their contents. /markClean FAT/FAT32/exFAT only: Mark the volume clean if no corruption was detected even if /F was not specified.

Examples

CHKDSK C: /F

Fixing Errors /F

If the drive is the boot partition, you will be prompted to run the check during the next boot

If you specify the /f switch, chkdsk will show an error if open files are found on the disk.

Chkdsk /f will lock the volume, making data unavailable until chkdsk is finished.

If you use chkdsk /f on a disk with a very large number of files (millions), chkdsk can take a long time to complete.

When you delete a file or folder that has 'custom' permissions, the ACL is not deleted, it is cached. Chkdsk /f will remove ACLs that are no longer used. This is often the cause of the rather worrying message: "Windows found problems with the file system. Run chkdsk with the /F (fix) option to correct these."

It is normal for chkdsk /F to remove unused index entries and unused security descriptors every time you run it, these do not indicate a problem with the file system.

Scan only (without /f switch)

If a file needs to be fixed chkdsk will alert you with a message but will not fix the error(s).

chkdsk can report lost allocation units on the disk - it will produce this report even if the files are in-use (open). If corruption is found, consider closing all files and repairing the disk with /F.

Running chkdsk on a data volume that is in use by another program or process can incorrectly report errors when none are present. To avoid this, close all programs or processes that have open handles to the volume.

On computers running Windows 2003 SP1 and later, chkdsk automatically creates a shadow copy, so you can check volumes that are 'in use' by another program or process. This enables an accurate report against a live file server. On earlier versions of Windows, chkdsk would always lock the volume, making data unavailable.

Run at Bootup

Running at bootup is often the easiest way to close all open file handles.

Use chkdsk, chkntfs or the FSUTIL dirty commands to set or query the volumes 'dirty' bit so that Windows will run chkdsk when the computer is restarted. This setting is also found in the BootExecute value under HKLM\System\CurrentControlSet\Control\Session Manager

Event Logs

Chkdsk will log error messages in the Event Viewer - System Log.
Chkdsk /f removes ACLs that are no longer used and reports this in the Event Viewer - Application Log.

Cluster (or block) Size

CHKDSK produces a report that shows the the block /cluster size
typically: "4096 bytes in each allocation unit."
When the cluster size is greater than 4 KB on an NTFS volume, none of the NTFS compression functions are available.

Exit codes

0 No errors were found
1 Errors were found and fixed.
2 Could not check the disk, did not or could not fix errors.

Notes:
Consider the time required to run Chkdsk to repair any errors that occur. Chkdsk times are determined by the number of files on the volume and by the number of files in the largest folder. Chkdsk performance was improved by 30% under Windows 2003 and around 50% in 2008 R2.

To issue chkdsk on a hard drive you must be a member of the Administrators group.

When CHKDSK is set to run at boot-up there is a delay to allow the check to be cancelled - this can be configured in the registry:

HKLM\System\CurrentControlSet\Control\Session Manager
REG_DWORD:AutoChkTimeOutData
The value is the time in seconds that you want CHKDSK to wait (0 = no delay) default is 10 seconds.

Chkdsk is also available from the Recovery Console (with different parameters.)

Disk Errors

"The file system structure on the disk is corrupt and unusable"

If you have disk corruption, run the drive manufacturers diagnostics:
Toshiba | Hitachi/IBM | Seagate/Maxtor/Freeagent | Western digital

“I either want less corruption, or more chance to participate in it” ~ Ashleigh Brilliant

Related commands

CHKNTFS - Schedule CHKDSK to run at boot time.
FSUTIL - Set options to control the operation of CHKDSK
FSUTIL dirty query C: - Is the drive dirty.
CleanMgr - Automated cleanup of Temp files, recycle bin etc.
Q187941 - New /C and /I Switches.
Q303079 - Locate and correct NTFS problems.
Q310747 - System File Checker (Sfc.exe) .
Q327009 - Chkdsk Finds Incorrect Security IDs.
Q329394 - Long Delays Occur When You Run Chkdsk.exe
Ultimate Boot CD - Recovery tool.
HDTune - Performance & SMART Info. (Self-Monitoring Analysis and Reporting Technology).
Equivalent bash command (Linux): fsck - filesystem consistency check and interactive repair.


 
Copyright © 1999-2024 SS64.com
Some rights reserved