Use of the CHKDSK (Disk Detection) command

  

The CHKDSK command checks the status of the disk and displays status reports, as well as correcting disk errors.

The status report shows a logical error in the MS-DOS file system consisting of a file allocation table (FAT) and a directory (CHKDSK does not verify that the information in the file can be accurately read). If the disk has an error, CHKDSK will give a warning message. Therefore, from time to time, use CHKDSK to check the disk for errors to ensure the normal operation of the system.

First, the syntax of the CHKDSK command

CHKDSK drive:[[path]filename][/F][/V]

To display the disk status of the current drive, Available commands:

CHKDSK

II. Explanation of parameters of CHKDSK command

(1)drive

Specify the drive where the disk to be checked with CHKDSK is located.

(2)[path]filename

Specify the path and name of a file or group of files to be checked by CHKDSK. Use wildcards (* or ?) to specify multiple files.

Third, the switch item of CHKDSK command

(1)/F

Correct the disk error. Note that you should not select this option when running CHKDSK from other applications (such as Windows).

(2)/V

When the disk is checked, the files in each directory are displayed.

IV. Access to help information

If you don't know the usage of the CHKDSK command, don't hesitate to enter CHKDSK/at any time under DOS? You can understand its usage.

V. Notes on CHKDSK Commands

(1) Forms of Status Reports

MS-DOS displays status reports of CHKDSK in a form similar to the following:

Volume MS-DOS_6 created 07-16-1996 10:40a

Volume Serial Number is 2111-59F0

629,424,128 bytes total disk space

638,976 bytes in 15 hidden Files

1,146,880 bytes in 70 directories

120,766,464 bytes in 1,802 user files

506,871,808 bytes available on disk

(2) Fix disk errors

When correcting disk errors, it is best to use the ScanDisk program. See the (SCANDISK) command for details. Use the CHKDSK/F command to correct the disk error display information as follows:

10 lost allocation units found 3 chains

convert lost chains to files?

If you press Y, MS -DOS stores each missing chain in the root directory as a file name in the form of FILEnnnn .CHK, nnnn is a number starting from 0000. After the CHKDSK check is finished, you can check whether the files contain the required data. If you have them, you can edit them and use them. Otherwise, you can delete them all to avoid taking up disk space. If N is selected, MS-DOS only corrects the disk but does not save the contents of the lost allocation unit.

If the /F switch is not used, CHKDSK will display a message to remind the user if the file needs to be corrected and restored, but the actual error correction is not performed.

(3) ERRORLEVER parameter

If CHKDSK does not find any error, the value returned to ERRORLEVER is 0. If one or more errors are found, the value of ERRORLEVER on return is 255.

VI. Precautions for using the CHKDSK command

(1) When the system has an open file

Do not use CHKDSK when a file is open. Because CHKDSK is designed to assume that the disk file is closed. When a file is opened, the corresponding MS-DOS will modify the file allocation table and directory structure. This change does not necessarily occur immediately, and changes to the file allocation table and directory structure occur at different times. Therefore, if CHKDSK is run when the file on the disk is opened, the inconsistency of the directory structure and the file allocation table will be interpreted as an error, resulting in data loss or file system corruption. Therefore, do not run CHKDSK when running other programs, such as Microsoft Windows.

(2) CHKDSK cannot be used for assigned drives and networks.

CHKDSK cannot be used for drives that are formed by SUBST commands, nor for disk checks on network drives.

(3) Physical Disk Error

The CHKDSK command can only find logical errors in the file system, not physical disk errors. To find physical disk errors, use the SCANDISK program.

(4) Bad disk sector

In the CHKDSK report, bad sectors are marked with "bad", and SCANDISK and other physical disk error correction programs also mark bad sectors as "bad". Therefore, bad sectors will not cause harm.

(5) Cross-linked files

If there are two files or directories sharing records of the same disk space, CHKDSK will report cross-linked files. If CHKDSK finds that a cross-linked file exists, it will display something like the following:

<File> is cross linked on allocation unit <number>

CHKDSK will not patch cross-linked files, even The /F item is specified. To fix cross-linked files, you need to run the SCANDISK program, or manually fix it, then copy it to the specified file and delete the original file.

VII, application examples

(1) save the status report of CHKDSK to the file

The CHKDSK status report can be redirected and output to a file for saving, but pay attention to Do not use the /F switch when directing CHKDSK output to a file. For example, the information of the CHKDSK check is output to the CHK.LIS file, and the command is: C:\\DOS>CHKDSK A:>CHK.LIS.

(2) If you check how much data is stored in the C drive, how much free space and correct disk errors, you can enter the following command:

CHKDSK C:

When an error occurs, CHKDSK will pause and prompt for a message.

(3) Find files

Use CHKDSK and FIND commands to combine the pipeline function to achieve full file search. This command format can not only list the directory where the files are found, but also List files of the same name in each directory, even hidden files. It is worth noting that before using this command, you should first correct the disk error with the CHKDSK/F parameter. For example, look up the README file on the C drive. The command format is as follows:

C:>CHKDSK/VIFIND "README"

Copyright © Windows knowledge All Rights Reserved