In the second half of 2002 I had an Operating System class at Uni. I was disappointed that our class only devoted an hour or two at the most to file system design and never got past discussing basic theory. So I read up on some of the file systems that I'd heard of and ended up writing this after having difficulty finding a clear complete summary of the FAT file system.
Since then I've added some of the content here to the
File Allocation Table page on Wikipedia. If you want to learn more I suggest you go there as that page is more likely to be updated than this one.
Introduction
The File Allocation Table (FAT) file system used by MS-DOS and Windows is based around two structures. The File Allocation Table (FAT) which stores the location of the data blocks of the files and the Directory Table which maintains the directory structure of the file system.
FAT Table
The available space on hard drives is divided up into clusters. A single file on the hard drive may store its data in one or more of these clusters, as many as are required by its size. Each cluster on the hard drive is represented by an entry in what is called the FAT table. An entry within the FAT table basically indicates one of three things. Either it contains a value that indicates the location of the next data cluster of the file or a special End Of File (EOF) character that indicates the represented cluster is the last data cluster of the file or a zero value to indicate that the represented cluster is empty.
Directory Table Entry
A directory in MS-DOS FAT is a special file with a table structure. Each entry (32 bytes long) within the table represents a file or another directory. These entries hold metadata about the file such as the file's name, extension and attributes (e.g. hidden, archived), date and time the file/directory was created, the size of the file and the cluster number of the first cluster of the file's data.
FAT16 Directory Table Entry Structure
| MetaData | Size |
| name | 8 bytes |
| extension | 3 bytes |
| attributes | 1 bytes |
| reserved | 10 bytes |
| time | 2 bytes |
| date | 2 bytes |
| first data block number | 2 bytes |
| size | 4 bytes |
Difference between FAT16 and FAT32
- FAT16 supports hard drives up to a maximum between 2GB and 4GB
- FAT32 supports hard drives sizes between 260MB and 2TB.
- Cluster size differs...
| Disk Size | FAT16 Cluster Size | FAT32 Cluster Size |
| 0MB - 128MB | 2K | N/A |
| 129MB - 256MB | 4K | N/A |
| 257MB - 512MB | 8K | 4K |
| 513MB - 1GB | 16K | 4K |
| 1GB - 2GB | 32K | 4K |
| 2GB - 4GB | 64K | 4K |
| 4GB - 8GB | N/A | 4K |
| 8GB - 60GB | N/A | 8K |
| 60GB - 2TB | N/A | 16K |
| 2TB - ? | N/A | 32K |
- The actual FAT table is larger in FAT32 because each entry in the table uses 32 bits (4 reserved), whereas FAT16 uses 16 bits per table entry.
- The root directory in FAT16 is expected to be at a certain location, whereas with FAT32 it is stored as an ordinary chain of clusters so it can be stored anywhere and also grow to any size.
- FAT32 creates a backup copy of critical data structures in the boot record, to reduce the chance of file system corruption.
History
1996: FAT32 debuts in Windows 95 OEM Service Release 2.
1981: FAT16 debuts with MS-Dos.
1977: Bill Gates and Marc McDonald write the first version of FAT, during the development
of "Microsoft Disk Basic".
Sources