An example of the sectors in the four areas
Let us look at a FAT formatted hard disk with 160 MB: How are the sectors utilized?
Note: My calculations in this example are NOT 100% CORRECT, as a few bright readers have noticed. I am sorry. However, use them as an indication of how the disk is subdivided. One day I hope to give the correct picture...
The partition contains exactly 157.9 MB, if we calculate correctly. We are talking about 165,656,576 bytes. The total data storage area is divided in 323,549 sectors, 512 bytes each. If you multiply, that results in 165,656,576 bytes:
323,548 sectors x 512 bytes = 165,656,576 bytes.
This equals to 157.9 MB as you can see from this:
|= 165,656,576 bytes
divided with 1024 =
divided with 1024 =
The file system now assumes control over these 323,548 sectors. The boot record occupies the first sector . In the following you find a brief description of the boot record and other administrative areas.
The boot record information enables the file system to handle the disk. At the same time, it includes a small program to use during system start-up. Here is a summary of that sector's contents (skip, if you do not understand):
|8086 instruction (JUMP).|
|DOS name and version number.|
|Bytes per sector.|
|Sectors per cluster in the data area.|
|Number of reserved sectors.|
|Max. number of entries in the root directory.|
|Total number of sectors.|
|Media description (is this a hard disk?).|
|Number of sectors per FAT|
|Number of sectors per track.|
|Number of disk read heads.|
|Number of hidden sectors.|
|BOOT-strap program routine, which reads the hidden file (like IO.SYS), which starts the operating system.|
The FAT areas
The FAT file administration is actually a very simple system, but it is complicated to describe. Later, I will show some practical examples. Here is the first description. Even if you do not entirely understand the following, do not give up.
FAT consists of a table of whole numbers, which has 65,536 16-bit entries . Each of these entries contain information about a cluster.
The content of each FAT entry consists of a whole number . In the table below, they are written as four digit hexadecimal numbers, which show one of four options.
|Possible FAT cluster entry||Value|
|The cluster is part of a file, the last in the file.||FFFF|
|The cluster is part of a file. You can read the
number of the next cluster in the same file.
|The cluster is empty, thus free.||0000|
|The cluster contains defective sectors.||FFF7|
Example on reading a file
When the file system has to read a file, it follows this routine. We imagine that the file occupies 4 clusters and it occupies cluster numbers 442, 443, 444, and 448. But how does the operating system read these addresses?
FAT always works in this way. Whenever a file has to be read, its location is read in the table. Every time a file has to be written to a disk, vacant clusters must be found for it, and the information is stored in FAT, to facilitate retrieval.
One of the great advantages of disk
cache programs are, they always have a copy of FAT in RAM. In this
way the disk cluster "map" can be read much faster than if the operating
system had to read the FAT from the disk at each request.
Let us return to the sector account in the example of a disk of 160 MB size:
The maximum FAT size is 128 KB, since 2 16 files, 2 bytes each, equals 65,536 x 2 = 131,072 bytes or 128 KB. In our example, there turns out to be 40,400 clusters , since the disk partition is 160 MB.
We have two FATís, at 40,400 X 2 bytes. That comes to a total of 161,600, and that will occupy 316 sectors.
The last administrative area on the disk is the root directory. Since there are always 512 file or directory entrances in the root directory, it is the same size on all hard disks. The root directory is unique in its fixed size and its location in the root. Other than that, it is a directory like any other.
Actually, a directory is a list of files and other directories. Thus, you can read the names of files and sub directories in the directory! The directory structure consists of a number of directory entries.
Let us look at these directory entries, each of which occupies 32 bytes. The directory entries are identical, whether they are in the root directory or a sub directory.
All sub directories have at least two entries. They are rather special , in that they refer to the directory itself and to its "parent" directory (in which it is a sub directory). The entries can be seen with the DOS command DIR.
The entry for the directory itself is seen as one dot. The entry for the parent directory is seen as two dots.
The sectors in the data area are allocated in clusters. As mentioned before, the maximum number of clusters for data is 2 16 = 65,536. Our hard disk is 160 MB. That results in 40,400 clusters, 8 sectors each.
All sub directory entries in the data area are organized in 32 byte files, which contain the same fields as the root directory entries.
Here is a graphic illustration of the same distribution:
Read Module 6b with a little about Windows 95/98.
Read Module 6c about the relationship between BIOS, OS and hardware
Read Module 7a about the videosystem
Read about video cards in Module 7b .
Read about digital sound in Module 7c .
Copyright (c) 1996-2017 by Michael B. Karbo. www.Karbosguide.com.