This is only a preview of the March 1992 issue of Silicon Chip. You can view 39 of the 96 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Articles in this series:
Articles in this series:
Articles in this series:
|
COMPUTER BITS
BY JENNIFER BONNITCHA
How to cope with damaged
directories & file allocation errors
Continuing on with troubleshooting
tips for your PC, this month we look
at problems such as non-DOS discs,
damaged directories, allocation
errors and invalid clusters.
Each disc used by DOS must first be subdivided into
tracks and sectors. You can think of tracks as a series of
concentric circles covering the disc surface (Fig. l). The
tracks are numbered from the outer edge to the inner edge
as track 0, track 1, track 2 and so on. Additionally, discs
with more than one side have their sides numbered,
starting with 0, then side 1.
Finally, tracks are divided like pie slices into sectors,
starting with sector 1, then sector 2 and so on. Typically,
sectors have a storage capacity of 512 bytes.
You can work out disc capacity with the following
formulas: (1) No. bytes per sector x No. sectors per track=
no. bytes per track; (2) No. bytes per track x total no. tracks
= disc storage capacity
Sector 7
Sector 3
Fig.1: how a computer disc is divided into tracks & sectors
by the FORMAT procedure.
SILICON CHIP
Disc formatting
Tracks and sectors are constructed during the disc
FORMAT procedure, which also places a copy of the DOS
boot record in sector 1, track 0, side 0. This record has a
table containing information about the disc and machine
language code that loads two system files into memory.
Format also constructs the File Allocation Table (FAT)
and the file directory.
The file directory is just like a table of contents for a
disc. Every file on the disc has a corresponding entry in
the disc's file directory; each entry is composed of 32
bytes which in turn are partitioned into 8 fields. Finally,
each of these 8 fields contains information used by DOS in
file management, such as a file's name, extension, time
and date stamp, starting cluster, etc.
File allocation table
Sector 8
Sector 1
52
Hard discs consist of one or more platters, each with
two surfaces. These platters are also divided into tracks
and the tracks into sectors. All tracks with the same
radius form a cylinder through the platters. Note, however, that the layout of hard drives varies according to the
manufacturer and disc capacity.
While the disc directory tells you which files are present
on a disc, the FAT tells DOS where a file's contents are
actually located. DOS divides each file's contents into
clusters which are numbered according to their physical
location on the disc. The first cluster starts with the sector
immediately following the last sector of the file directory;
the second cluster follows the first and so on.
An invalid entry for the FAT is a cluster number that
points to a non-existent cluster on the disc. The entry is
either 1 (which is invalid since DOS starts with entry 2 on
the disc) or a number higher than the number of clusters
for the disc. Without the FAT, DOS would be unable to
access any files. It is so important to the running of your
computer that a second copy is stored on each disc.
Should you experience an Invalid Cluster message
while running CHKDSK, you can be reasonably sure it is
the result of an unexpected system shutdown or a poorly
behaved program. You can expect to see one of two
messages from CHKDSK if this is the case:
<filename> First cluster number is invalid, entry
truncated; or
<filename> has invalid cluster, file truncated
In the first case, the starting cluster number in the file's
directory entry doesn 't make any sense since DOS doesn't
know where the file's chain is in the FAT. The second
message indicates corruption in the FAT file chain at the
point of the invalid cluster. In either case, DOS determines that the file's entry in the file directory indicates
that the file is larger than the amount of disc space
allocated for it in the FAT.
The errors typically occur during an update operation,
so you could try using a backup of the fil e (which will be
out-of-date but intact), or you could try recovering the
file . You have some chance of manual repair, provided
you do not use CHKDSK/F. The IF switch in this instance
truncates the file at the invalid cluster number so that its
size matches the allocation specified by the FAT. The part
of the file beyond the invalid cluster is then lost.
Recovery, while not impossible requires some luck and
a good knowledge of both DOS and the FAT. If you are
desperate, try a disc-sector editor such as the Norton
Utilities and follow the associated instructions. The general idea is to change the wayward entry to point to the
next cluster of the disc.
More orphans
CHKDSK may report orphaned and invalid clusters
within the FAT. Usually the orphaned clusters belong to
the file whose FAT chain is broken. You should run
CHKDSK/F and convert the lost chains/clusters to files
then examine each of the files created by the procedure. If
the information is worth saving, use the copy command:
COPY <filename>+FILE000l .CHK+FILE0000.CHK
[d:}<filename> IB
The /B switch causes COPY to treat the file(s) as a binary
file. If a file is to be copied, this switch tells COPY to copy
the entire file based on the size stored in the file directory.
If the file is to be a copy, the switch tells.COPY not to place
an end-of-file marker at the end of the file. Examine the
result of your file concatenation command then delete the
CHK files created by CHKDSK, together with the originally
suspect file.
Should you get a message indicating an invalid starting
cluster, DOS has lost track of the entire FAT chain(s) for the
file. Chances are good that the chains still exist on the
disc. Once again run CHKDSK/F to truncate the file and
generate a series of CHK files containing the orphaned
clusters. Once again examine each of the CHK files and try
to piece together the file.
Allocation errors
Inconsistencies between the file size in the directory
entry and the number of clusters allocated to the file in
the FAT produce the following message:
<filename> Allocation error for file, size adjusted
As a general rule, the file's information has been successfully written to the disc; the problem is simply that
the file size in the directory entry is too large or small.
Although serious problems seldom occur as a result of
this procedure, you may find some extra information at
the end of the file in question. Possibly some information
may be deleted which will cause the program using the
file to object.
Finally, ensure that the allocation error is for a file.
Should CHKDSK report this error for a directory, you may
be in serious trouble. A good starting point once again is
the Norton Utilities' Disk Doctor. The program is menudriven and easier to understand than CHKDSK; it will
diagnose and repair many logical and some physical disc
problems.
While there are certainly other programs which will
help with these problems (MACE Utilities, PC Tools, etc),
Norton Utilities is my personal favourite. Any one of the
utilities is a good investment for all computer users.
Non-DOS discs
From time to time, you may receive the following
message, even when you have previously used a disc:
Probable non-DOS disk
Continue (YIN)?
CHKDSK checks each disc to make sure it is a DOS disc ,
since it has the capability to alter the information contained therein. By examining the first two entries of the
FAT (where the media ID is stored) and the second sector
of the disc, CHKDSK can determine the disc's status. If the
media ID byte is invalid, CHKDSK reports a potential nonDOS disc.
In this situation, it's possible that the disc is either
unformatted or has been formatted under a different operating system.
If you get this message periodically, you may have a
program or hardware problem which mangles the FAT.
Once again the disc editor can repair the damage - compare the two copies of the FAT, then correct the media ID
byte and write the sector back to the disc.
Directory errors
All subdirectories have two entries placed when the
directory is created - the "." (dot) and" .. " (double dot).·
The single dot entry designates the parent of the current
directory while the double dot is the current directory.
Should CHKDSK report that the "." or " .. " entry has a bad
attribute (or link or size), the first or second subdirectory
entry is defective.
The only DOS attribute usually set to ON for a subdirectory is the directory attribute. If CHKDSK reports a
bad link, the starting cluster number for the directory is
incorrect. Badly behaved programs can cause the special
subdirectory entries to have problems with their file
attributes, size or FAT linkage.
Run CHKDSK/F to repair most of the above problems,
provided the parent directory is undamaged. If the parent
should happen to be damaged, CHKDSK will display more
warning messages. You may get the following:
Processing cannot continue
Unrecoverable error in directory
Convert directory to file (YIN)?
The first message indicates that the disc structure may
be so badly damaged that CHKDSK is confused. Respond
"N" then try re-booting DOS and run the command again.
If you continue to get the message, try to back-up the disc
then run CHKDSK/F and convert the subdirectory to a file.
However, in converting the subdirectory to a file, all files
in this and subsequent subdirectories will become orphaned clusters. You could try to rebuild the files you did
not back-up or delete the subdirectory and files , then use
a previous back-up.
SC
MARCH 1992
53
|