1. Determining File and Directory Status with the ChkDsk Utility
The ChkDsk utility has
been around in various forms from the days of DOS—before Windows
appeared on the scene. Of course, Microsoft keeps adding features to
this utility and it now runs as part of Windows, instead of part of DOS,
but the concept remains the same. You use ChkDsk to perform a basic
check of the hard drive. In addition, you can optionally use it to
recover lost clusters and attempt repairs on damaged clusters. This
utility uses the following syntax:
CHKDSK [volume[[path]filename]]] [/F] [/V] [/R] [/X] [/I] [/C] [/L[:size]] [/B]
The following list describes each of the command line arguments.
/F
Adds fixing media errors to the list of tasks to perform. This switch differs from /R, which recovers clusters lost when an application terminates unexpectedly.
/R
Adds recovering lost clusters to the list of tasks to perform. Using this switch also adds the /F switch automatically.
/V
Displays the full path and name of every file on the disk. Use this switch only on FAT- or FAT32-formatted drives.
/L
[Size]Outputs the current size of the log file used to track drive activity when you use the /L
switch alone. Including the optional log file size modifies the size of
the log for the current drive. Theoretically, a larger log could help
improve drive reliability, but in practice, the default size normally
works well. Use this switch only on NTFS-formatted drives.
/X
Forces the
operating system to dismount a drive before performing a check.
Dismounting the drive makes all drive resources unavailable, but also
ensures uninterrupted access by ChkDsk, which can help improve the
results of any tasks performed. The operating system must mount a drive
before you can access the drive contents again. Use this switch only on
NTFS-formatted drives.
/I
Performs a less
robust check of the drive indexes (the portion of the drive used to
locate files). Normally, you won't use this switch when you want to
check a drive for optimum performance. However, you can use this switch
to reduce the time required to check the drive. Use this switch only on
NTFS-formatted drives.
/C
Skips checking
cycles within the drive folders. When a folder contains cyclical
references, damage to the files can result. Consequently, even though
this switch does reduce the time to check the drive, you want to avoid
using it because ChkDsk doesn't thoroughly check the drive otherwise.
Use this switch only on NTFS-formatted drives.
/B
Reevaluates bad
clusters on the hard drive. If the cluster is readable, ChkDsk places it
back into service. This option is only available on NTFS drives and
using it also includes the /R command line switch.
To use ChkDsk to perform a basic check, type ChkDsk
at the command prompt and press Enter. ChkDsk always assumes that you
want to check the current drive. When you want to check a different
drive, add the drive letter to the command. In addition, when you're
working a FAT-formatted drive, you can specify a specific file. For
example, you could type ChkDsk C:\DRVSPACE.BIN to check the DRVSPACE.BIN file on drive C.
NOTE
You can't use ChkDsk directly on the Windows (boot) drive with either the /F or /R
options because Windows needs access to specific files at all times.
Use the ChkNTFS utility to repair the Windows drive. It's possible to
use ChkDsk in the read-only mode to look for potential errors without
fixing.
2. Performing Boot Time Disk Checks with the ChkNTFS Utility
Most
of the hard drives used with Windows today rely on NTFS because it's
more robust. It provides data encryption, extra security, and built-in
file compression. In addition, NTFS is more reliable than the older FAT
file system. (Even though you can't install Server Core on a FAT
formatted drive, you can still use it to access FAT formatted drive,
such as flash drives, so it's still important to know about the FAT file
system.) However, NTFS also requires a little more care at times
because it's more complex than FAT. The following sections describe how
to use the ChkNTFS utility and how the associated AutoChk application
enhances ChkNTFS at boot time.
2.1. Using the ChkNTFS Utility
The ChkNTFS utility
works with ChkDsk to ensure your system remains problem free. You won't
see the effects of this utility right away in most cases. This utility
sets up your drive to use ChkDsk during the boot process, rather than
after Windows has booted, to ensure you can gain full access to the
drive. The drive repair can occur without Windows interference. When you
select a drive for a scan, ChkNTFS says that it's dirty. Therefore,
when you see that the drive isn't dirty, that means ChkNTFS hasn't
scheduled it for a check. A drive can also become dirty when Windows
detects an error on it. This utility uses the following syntax:
CHKNTFS volume [...]
CHKNTFS /D
CHKNTFS /T[:time]
CHKNTFS /X volume [...]
CHKNTFS /C volume [...]
To use ChkNTFS, you
must provide a drive argument or one of the command line switches at a
minimum. When you supply a drive argument, ChkNTFS tells you the drive
format and determines whether Windows has scheduled it for a check. The
following list describes each of the command line arguments.
volume
Determines the
volume to check for errors. You can specify the volume using a drive
letter followed by a colon, a mount point, or a volume name.
/D
Places all of the
drives in the default state. You can use this switch to remove a drive
from the checklist when you schedule the check. This switch won't
reverse a mandatory check due to an error detected by Windows.
/T
[:Time]Tells how much
time the utility allows before it begins the check sequence during boot
time when you use this switch by itself. The automatic countdown lets
you decide at boot time whether to run ChkDsk as planned. Supplying the
optional time value modifies the count-down timer to give the user more
or less time to make the ChkDsk decision. The default automatic
countdown value is 10 seconds.
/X
VolumeExcludes one or more
drives from a check. You use this option when you set up the system to
perform ChkDsk every time it boots. This is a one time switch—Windows
excludes the drive for one boot cycle.
/C
VolumeSchedules a drive for a check during the next boot cycle.
You don't have to use
ChkNTFS to perform some tasks. For example, when you want to set up a
drive for a scan, right-click the drive in Windows Explorer and choose
Properties from the context menu. Select the Tools tab and click Check
Now. You'll see a Check Disk dialog box. Check both of the repair
options and click Start. When working with a boot drive, Windows
Explorer displays an error saying that it couldn't complete the check.
It then offers the chance to perform the check later during the next
boot. Click Yes and Windows Explorer sets up the check.
|
|
2.2. Understanding How AutoChk Works with ChkNTFS
AutoChk is a
non-Windows application; you can't run it from the command prompt.
However, the utility does run during the boot process, which is when
you'll see it at work. The AutoChk utility determines which volumes to
check at boot time based on entries it finds in the registry. The HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
key normally contains a value that indicates that AutoChk should check
all volumes for the dirty bit (attribute), which means that they require
a boot time check.
The dirty bit is an
indicator. You can manually set the dirty bit by using the ChkNTFS
utility or request that the system set it when using the ChkDsk utility
on a drive that is locked. In addition, the system sets the dirty bit
whenever one of a number of errors occurs. Finally, you can modify the
registry so that AutoChk performs specific tasks whenever you boot the
system. The Microsoft Knowledge Base article at http://support.microsoft.com/kb/q218461/ provides additional information on this topic.
It's
important to note the correspondence between commands you enter at the
command prompt using ChkNTFS and the corresponding change to the
registry that results in AutoChk running during the boot process. For
example, if you enter ChkNTFS D: E: /X at the command prompt, the system actually enters Autocheck AutoChk /k:D /k:E * into the registry. The /k AutoChk command line switch excludes the specified drive from checks during the boot process.