Lloyd Robert Borrett

  search
 
Follow Lloyd on Twitter Friend Lloyd on Facebook Connect with Lloyd on LinkedIn Follow Lloyd on Pinterest
Computing

CHKDSK, a Command That's Misunderstood

by Lloyd Borrett
Today's Computers, Wizard's Notebook, November 1985

  Wizard's Notebook

Wizard's Notebook

One of the most misunderstood DOS commands is CHKDSK. At first it may seem trivial. After all its primary purpose is simply to determine the amount of space remaining on a given disk. There are, however, several other uses for the CHKDSK command.

Unfortunately, for one to fully understand CHKDSK one must also have knowledge of the internal structure of the DOS directory system. That would take many pages of explanation so instead let us concentrate on the essentials.

A quick reading of the IBM DOS manual may lead you to believe that CHKDSK is used to report the status of the directory and File Allocation Table for the specified disk. In fact CHKDSK does more than report the status of the directory and FAT, it modifies them if it finds an error. For example, if CHKDSK discovers a FAT entry containing a number that is too large to represent a physical sector, it will set that allocation block back to its free state, so that it can again be used to store a legitimate file.

Another of CHKDSK's interesting efforts is directed toward the freeing of disk allocation units that are marked "in use" by the FAT but do not belong to any file. Such a situation often arises if an application program fails to obey the laws of DOS.

When applied to a normal disk, CHKDSK returns a report that looks like this:

Volume MAIN DISK created Aug 16, 1985 6:57p
21225472 bytes total disk space
   32768 bytes in 3 hidden files
  147456 bytes in 18 directories
 6348800 bytes in 400 user files
14671872 bytes available on disk
 
  655360 bytes total memory
  321376 bytes free
 

CHKDSK may also return a report that states 24576 bytes in bad sectors if it discovers that certain sectors have been marked as damaged.

The command may also return one or more error messages, each of which indicates the existence of an abnormal condition. The more important CHKDSK messages include:

  • Allocation error for file filename.
    Indicates that an invalid allocation unit number was discovered in the FAT. CHKDSK "de-allocates" the offending allocation unit and truncates the file at the end of the previous allocation unit. If the file contains a program, then this measure is futile, since the program has probably been rendered unusable. If, on the other hand, the file contains data, then some data may be saved.
     
  • xxxxxxxx bytes disk space freed.
    This error message indicates that allo¬cation units formerly marked as used, but not actually in use, have been "de-allocated".
     
  • Directory error-file: filename.
    Indicates that a directory entry was discovered for a nonexistent file. In other words, there were no allocation units assigned to this file. CHKDSK removes the phantom file from the directory.
     
  • Diskette (or Drive) not initialized.
    If CHKDSK can not find the directory or FAT, it assumes the disk has never been formatted. If this happens with a disk that you know has been formatted, first try to DISKCOPY the disk. If that fails, try to COPY all files to a new disk. In most cases, this attempt will not be any good at all, but that's okay — you did make a backup, didn't you?
     
  • File size error for file filename.
    This error message is returned when CHKDSK discovers that the size of a file as indicated by the directory entry does not agree with the actual size of the file, which it can calculate by counting allocation units. If this happens, CHKDSK adjusts the figure contained in the directory entry.
     
  • Files cross-linked: filename and filename.
    When CHKDSK emits this error message it means that it has discovered two directory entries that describe the same data block. A situation like this is not likely to arise, but in any case it is not lethal as far as data integrity is concerned, so CHKDSK does not take any action. It leaves it up to you to correct by copying both files to different file names, then erasing both of the original directory entries.

In addition to these error messages, there are also the usual DOS error messages that may crop up from time to time. All of these are self-explanatory and easy to correct.

It is quite essential that CHKDSK be run on a regular basis, especially if you are using a fixed disk drive. Before doing a backup, always run CHKDSK. There is no point in wasting your time backing up a corrupted disk. Unfortunately for many, CHKDSK is an essential command that has been totally overlooked or misunderstood. It's worth taking the time to become familiar with it.

Lloyd Borrett is support co-ordinator for HiSoft Computers, president of the Australian PC User Association, founder and president of the Melbourne PC User Group and system operator of the PC Connection bulletin board system.

Last modified: Saturday, 15 October 2011

 
 


 
 
home | about | weird mob | computing | interests | insight
Copyright © 1995-2018 Lloyd Borrett. All rights reserved.  ::  www.borrett.id.au
mob 0418 170 044  ::  tel +61 3 5904 9005  ::  email lloyd@borrett.id.au  ::  skype lloyd_borrett
twitter @borrett  ::  facebook lloyd.borrett  ::  linkedin lloydborrett