Home NT Commands
NT Syntax

chkdsk.exe

Check Disk - check and repair disk problems

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

key
   [drive:]   Specify the drive to check. 
   
   filename   Specify the file(s) to check for fragmentation (FAT only). 
   
   /F         Automatically Fix file system errors on the disk.
   
   /R         Scan for and attempt Recovery of bad sectors.
   
   /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 Skip directory corruption checks. /I Skip corruption checks that compare directory entries to the file record segment (FRS) in the volume's master file table (MFT)


For example:

CHKDSK c: /F

Running chkdsk without parameters on a data volume that is in use by another program or process may incorrectly report errors when none are present.

To avoid this, close all programs or processes that have open handles to the volume.

While inspecting or repairing volumes, chkdsk locks the volume, making any data stored on the volume unavailable until chkdsk is finished. As a rule, run chkdsk only on volumes that are known to be corrupt.

On servers that are infrequently restarted, use the chkntfs or the FSUTIL dirty commands to set or query the volume's dirty bit (indicating corruption) so that Windows runs chkdsk when the computer is restarted.

On volumes marked as "dirty," Windows automatically runs chkdsk when the computer is restarted.

Fixing Errors /F

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

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

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

If you use chkdsk /f on a very large disk or a disk with a very large number of files (millions), chkdsk may take a long time to complete. The computer will not be available during this time, as chkdsk does not relinquish control until it is done.

Scanning only (without the /f switch)

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

chkdsk may 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. Often the easiest method (even for non-primary partition drives) is to run the scan during bootup.

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 is improved significantly in Windows 2003.

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.

"I either want less corruption, or more chance to participate in it" - Ashleigh Brilliant

Related commands:

CHKNTFS - schedule CHKDSK to run at boot time.
Cleanmgr.exe - Windows 2000 disk cleanup
Q187941 - New /C and /I Switches
Q283340 - Windows XP does not detect corruption
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
Q873437 - Windows 2000 incorrectly identifies security descriptors

Equivalent Linux BASH commands:

cksum - Print CRC checksum and byte counts
fsck - filesystem consistency check and interactive repair



Simon Sheppard
SS64.com