The Windows Learning Center
>

How to Use Chkdsk in Windows XP

Learn how to use the Windows XP disk maintenance tool Check Disk (Chkdsk) to keep your PC healthy. The purpose and application of Chkdsk for disk error checking are explained.

Every Microsoft operating system since DOS has contained a tool for repairing corrupted file or folder structures and checking for bad disk sectors. In DOS it was called Chkdsk, in Windows 9X/Me it was called Scandisk, and in Windows XP (and Vista/7) we are back to the name Chkdsk.

What Chkdsk does and why it should be used

Chkdsk inspects the physical structure of a disk to make sure that it is healthy. It can repair problems related to bad sectors, lost clusters, cross-linked files, and directory errors. These types of problems can arise in a variety of ways. System crashes or freezes, power glitches, incorrectly turning off a computer can all cause corruption in the file or folder structure. Physically bumping or jarring a computer can cause the head that reads disks to hit the surface and damage sectors. Once some sort of error occurs it can propagate to create more errors so a regularly scheduled disk checkup is part of good system maintenance.

Chkdsk can also serve as an early warning that a hard drive is deteriorating. Disks gradually wear out and sectors may become bad. If Chkdsk starts finding bad sectors, that is a sign that a drive may need replacing. Unfortunately, many hard drive failures are sudden but nonetheless Chkdsk is an important line of defense.

How to run Chkdsk - Graphical interface

Chkdsk can be run as a command-line application or it can be run with a graphical user interface. Typical home PC users will probably use the latter so I will discuss it first. Chkdsk is not normally listed in the All Programs menu but is reached by the following steps:

  1. Open "My Computer" and right-click on the icon for the drive that is to be checked.
  2. In the context menu that opens, choose "Properties".
  3. Click the "Tools" tab at the top of the Properties window.
  4. In the "Error-checking" section, click the button "Check now".
  5. A box showing the options for running Chkdsk is then available as shown in the figure below.
Graphical interface for Chkdsk

Generally, the option "Automatically fix file system errors" should be chosen for routine checks. If serious disk problems are suspected, the option "Scan and attempt recovery of bad sectors" should also be checked. However, this may involve a period of many hours.

How to run Chkdsk - Command line

Chkdsk.exe is actually a command-line application and can be run from the command shell. There are a number of switches that can be used to modify its functions. The syntax of a command is

Chkdsk [volume[[path]filename]]] [/F] [/V] [/R] [/X] [/I] [/C] [/L[:size]]

Table I gives a description of the various terms and switches in the command.

Table I. Description of Windows XP Chkdsk command items
Switch Description
[volume] Specifies the drive letter (followed by a colon), mount point, or volume name.
[filename] FAT/FAT32 only: Specifies the files to check for fragmentation.
/F Fixes errors on the disk. Does not scan for bad sectors.
/V On FAT/FAT32: Displays the full path and name of every file on the disk. On NTFS: Displays cleanup messages if any.
/R Locates bad sectors and recovers readable information (implies /F).
/X NTFS only. Forces the volume to dismount first if necessary.
/I NTFS only: Performs a less vigorous check of index entries.
/C NTFS only: Skips checking of cycles within the folder structure.
/L[:size] NTFS only: Changes the log file size to the specified number of kilobytes.

(Windows Vista/7 also has a switch /B for re-evaluating bad clusters on a volume.)

Although Chkdsk can be run with no switches, the most useful application is to use either the /F or /R switches. This corresponds to the two options in the graphical interface discussed above. Note that running with the /R option can be quite lengthy. If there are unusually large numbers of files, the /F option can also take many hours. The /R switch includes the functions of the /F switch.

Running Chkdsk after a reboot

Chkdsk cannot carry out repair functions if any of the files on a disk are locked or in use. So it generally requires a reboot to run a check on any active volume with files in use. Chkdsk then runs before the full system is loaded and files become locked.

If you turn off your computer incorrectly, you may find that Chkdsk will run when you reboot. This is a safety feature to make sure that no file or folder corruption occurred.

Understanding how Chkdsk works

Chkdsk tests both FAT and NTFS systems. Here is a brief description of what Chkdsk does when it runs on an NTFS system. Chkdsk's activity is divided into three major passes plus an optional fourth and fifth pass. During each pass a message and a progress report is displayed.

Phase 1: Checking files

During its first pass, Chkdsk examines each file record segment in the volume's master file table (MFT) and examines it for internal consistency. At the end of this phase, Chkdsk has identified the space that is in use and the space that is available, both within the MFT and on the volume as a whole.

Phase 2: Checking indexes (directories)

During this pass, Chkdsk examines each directory that is on the volume, checking for internal consistency and verifying that every file and directory that is represented by a file record segment in the MFT is referenced by at least one directory. Chkdsk confirms that every file or subdirectory that is referenced in a directory actually exists as a valid file record segment in the MFT and also checks for circular directory references. Finally, Chkdsk confirms that the time stamps and file size information for the files are up-to-date in the directory listings for those files.

Phase 3: Checking security descriptors

During this phase, Chkdsk examines each security descriptor that is associated with files or directories on the volume. Security descriptors contain information about ownership of a file or directory, about NTFS permissions for the file or directory, and about auditing for the file or directory.

Phases 4 and 5: Checking sectors (optional)

If the /R switch is in effect, Chkdsk runs two more passes to look for bad sectors. During stage 4, Chkdsk verifies all clusters in use; during stage 5, Chkdsk verifies unused clusters. Note that this process can be quite lengthy. taking many hours.

Caution

Interrupting the Chkdsk process when it is used with the /F or the /R switch is not recommended. The integrity of the disk can be compromised by stopping the process. Do not start a scan if a thunderstorm is expected and you are subject to power failures. I also strongly advise an uninterruptible power supply to guard against short-term power outages or fluctuations.

Running Chkdsk from the Recovery Console

Chkdsk is available from the Windows Recovery Console and can be a very valuable tool in dealing with a system that does not boot properly. The use of the Recovery Console is discussed elsewhere but note that many systems have been rescued by the Recovery Console command:
chkdsk /R
Switches for the Chkdsk command in the Recovery Console are not the same as those in Table I. There are only two:

  • /P : Does an exhaustive check of the drive and corrects any errors. Does not check for bad sectors
  • /R : Locates bad sectors and recovers readable information. Includes functions of /P

Autochk.exe

The chkdsk command requires the file Autochk.exe. If it cannot find it in the startup directory (\%systemroot%\System32, by default), it will attempt to locate it on the Windows Installation CD.

More information

Two basic Microsoft references are the documentation here and the the Knowledge Base article here.