The FAT File System Part1

The FAT File System part 1 

The FAT (File Allocation Table file system has its origins in the late 1970’s. It was the file system that was used in the Microsoft MS-DOS operating system. It has been gradually improved and expanded. We know have 3 different versions of the FAT File System. FAT12,FAT16 and FAT32. The basic difference in these FAT sub types, and the reason for the names, is the size, in bits, of the entries in the actual FAT structure on the disk. There are 12 bits in a FAT12 FAT entry, 16 bits in a FAT16 FAT entry and 32 bits in a FAT32 FAT entry.


All versions of FAT have been designed for the IBM-PC with x86 architecture and therefore the data structures are in little endian.

A FAT file system is composed of 4 regions, which are setup in this order on the volume:
0 = Reserved Region
1 = FAT Region
2 = Root Directory Region (does not exist on FAT32)
3 = File and Directory Region

The first important data structure on a FAT volume is called the BPB (BIOS Parameter Block), which is located in the first sector of the volume in the Reserve Region. This sector is sometimes called the boot sector or the reserved sector or the “0th”sector.

FAT 16 was introduced with the Windows 95 Operating System and had a volume / partition limitation of 2GB. The 2GB Volume limitations was resolved with the release of the FAT32 file system.

Cluster:
This term is very fundamental for FAT. A cluster is a group of sectors on the FAT media. Only the part of the partition called the “data area” is divided into clusters. The rest of the partition is simply sectors Files and directories store their data in these clusters. The size of one cluster is specified in a structure called the Boot Record and can range from a single sector to 128 sectors.

Boot Record:
All the three flavours of FAT have a Boot Record, which is located within an area of reserved sectors. The DOS format program reserves 1 sector for FAT12 and FAT16 and usually 32 sectors for FAT32.

File Allocate Table:
The actual “File Allocation Table” structure is a relatively simple structure, as are all of the FAT structures really. The FAT is a simple array of 12-bit, 16-bit or 32-bit data elements. Usually there will be two identical copies of the FAT. There is a field in the Boot Record that specifies the number of FAT copies. With FAT12 and FAT16, MS-DOS uses only the first copy, but the other copies are kept in sync. FAT32 was enhanced to specify which FAT copy is the active one in a 4-bit value part of a “Flags” field.

Having a second copy of the FAT helps the Operating system during automated File system recovery or repair because of currutions in the FAT table as an example.

FAT32 specifications: Has 3 main regions, the Reserved Region, Fat Region and Data Region.

Reserved Region: Includes the boot sector, the extended boot sector, the file system information sector and a few other reserved sectors.

FAT Region:   A map used to traverse the data region. Contains mappings from cluster locations to cluster locations.

Data Region: Using the addresses from the FAT region contains actual file and directory data.

EOC = End of Cluster Marker: Note that the cluster number whose cluster entry in the FAT contains the EOC mark is allocated to the file and is also the last cluster allocated to the file. Microsoft operating system FAT drivers use the EOC value 0x0FFF for FAT12, 0xFFFF for FAT16, and 0x0FFFFFFF for FAT32 when they set the contents of a cluster to the EOC mark.

BAD CLUSTER Marker: There is also a special “BAD CLUSTER” mark. Any cluster that contains the “BAD CLUSTER” value in its FAT entry is a cluster that should not be placed on the free list because it is prone to disk errors. The “BAD CLUSTER” value is 0x0FF7 for FAT12, 0xFFF7 for FAT16, and 0x0FFFFFF7 for FAT32.

4 Replies to “The FAT File System Part1

  1. Sorry for off-topic, I’m thinking about making an instructive web site for college kids, is it ok if I link to your site for reference, I really enjoyed some of the technical content here.

  2. Great articles, I have bookmarked your blog. Hopefully you will provide some RSS, and some more content, that would be awesome!!!

  3. I like to get my inspiration from really meaningful phrases said by truly great people like “Man will never be free until the last king is strangled with the entrails of the last priest”, do you know where I can find thematic compiltaions of those?

Leave a Reply

Your email address will not be published. Required fields are marked *