DOS Days

The FAT (File Allocation Table) Explained

The File Allocation Table, or FAT, was a file system architecture designed by Bill Gates and Marc McDonald in 1977. At the time it was primarily considered for use with floppy disks only - only in later DOS versions would they support hard disks.

The FAT file system had a number of limitations that made it a poor choice for hard disks. Its use of clusters led to wasted disk space, its allocation of the disk led to fragmentation over time and thus loss of performance, no support for filenames beyond the 8.3 format, no support for extended file attributes, no support for large hard disks, and it was prone to data loss if the FAT itself became damaged. OS/2 version 1.2 alleviated these problems with the introduction of the HPFS (High Performance File System), and Windows NT did the same by introducing NTFS (NT File System). Of course, these different file systems were incompatible with one another so your choice of file system was what you were 'stuck' with unless you reformatted your hard disk.

Anyway, back to FAT...

The host operating system (DOS) is able to understand the contents of a volume (a floppy disk, a hard disk, etc) by reading the FAT.

When a volume is formatted, these sections are created in the FAT and written to:

1) Reserved Sectors - Information about the reserved sectors, including the 'boot sector' (also known as the VBR, the Volume Boot Record).
2) The FAT Region - Two identical copies of an "index table" which hold the details of all files and directories on the disk (these map directly to the Data Region).
3) The Root Directory Region - a dedicated "index table" that stores details of all files and directories that exist in the root directory.
4) The Data Region - this is where all files and directories are stored.

In the early PC days, there were two types of File Allocation Table structure: FAT12 and FAT16. FAT12 is so-called because it uses 12-bit entries for the cluster addresses. FAT16 uses 16-bit entries for the cluster addresses. Both FAT12 and FAT16 support only DOS 8.3 filenames. FAT32 was introduced with Windows 95 OSR2 (OEM Service Release 2). FAT32 can use much smaller cluster sizes, which helps reduce actual disk usage (files are stored at cluster size boundaries, so a 1-byte file in FAT16 may well use up 32 KB because the cluster size is 32 KB! The same file in FAT32 uses just 4 KB, as the cluster size is 4 KB. FAT32 also increased the partition size limit of 2 GB that FAT16 had.

Floppy Disks

In the case of DOS floppy disks, these all use FAT12. A volume using FAT12 has a theoretical storage limit of 32 MB and 4,068 files. There is also a limit on the name of an absolute directory path of 66 characters. A volume using FAT16 has a storage limit of 2 GB and 65,460 files.

Each entry in the FAT also has the following attributes:

  • Directory - set if the entry is a directory, not a file.
  • Read-Only - set if the file should not be altered. Read-only attributes on directories are usually ignored.
  • System - set if the file is an important system file, necessary for the operating system to function.
  • Hidden - set if the file is hidden. By default, the DOS 'dir' command does not show hidden files.
  • Archive - set if the file is awaiting backup. This attribute was sometimes used by third-party backup software which would un-set this flag after the file had been backed up.