Table of Contents

 


Introduction

File Allocation Table (FAT) is the name of a computer file system architecture and a family of industry standard file systems utilizing it. The FAT file system is a simple file system originally designed for small disks and simple folder structures. The FAT file system is named for its method of organization, the file allocation table, which resides at the beginning of the volume. To protect the volume, two copies of the table are kept, in case one becomes damaged. In addition, the file allocation tables and the root folder must be stored in a fixed location so that the files needed to start the system can be correctly located.
The major versions of the FAT format are named after the number of table element bits: 12 (FAT12), 16 (FAT16), and 32 (FAT32); each of these variants is still in use. The FAT standard has also been expanded in other ways while generally preserving backward compatibility with existing software.
The Windows FAT file system driver is implemented in the \Windows\System32\Drivers\Fastfat.sys file.

Return to top

Structure of a FAT Volume

The figure below illustrates how the FAT file system organizes a volume.


Figure 1: FAT file system volume organization.

The file allocation table contains the following types of information about each cluster on the volume

There is no organization to the FAT folder structure and files are given the first available location on the volume.
The entries in the file allocation table define the file-allocation chains (shown in Figure 2) for files and directories: the links in the chain are indexes to the next cluster of a file’s data. A file’s directory entry stores the starting cluster of the file, the last entry of the file’s allocation chain is the reserved value of 0xFFFF for FAT16 and 0xFFF for FAT12; the FAT entries for unused clusters have a value of 0. As you can see in Figure 2, FILE1 is assigned clusters 2, 3, and 4; FILE2 is fragmented and uses clusters 5, 6, and 8, while FILE3 uses only cluster 7. Reading a file from a FAT volume can involve reading large portions of a file allocation table to traverse the file’s allocation chains.
Sample of a FAT file-allocation chain

Figure 2: sample of a FAT file-allocation chain.

The root directory of FAT12 and FAT16 volumes is preassigned enough space at the start of a volume to store 256 directory entries, which places an upper limit on the number of fles and directories that can be stored in the root directory (there’s no preassigned space or size limit on FAT32 root directories ). A FAT directory entry is 32 bytes and stores a file’s name, size, starting cluster and time stamp (last-accessed, created and so on) information. If a file has a name that is Unicode or that doesn’t follow the MS-DOS 8.3 naming convention, additional directory entries are allocated to store the long fle name: the supplementary entries precede the file’s main entry. Figure 3 shows a sample directory entry for a file named “The quick brown fox.”: the system has created a THEQUI~1 FOX 8.3 representation of the name (that is, you don’t see a “.” in the directory entry because it is assumed to come after the eighth character) and used two more directory entries to store the Unicode long fle name; each row in the figure is made up of 16 bytes.
FAT directory entry

Figure 3: a FAT directory entry.

Return to top

The Partition Boot Sector

The Partition Boot Sector contains information that the file system uses to access the volume. On x86-based computers, the Master Boot Record use the Partition Boot Sector on the system partition to load the operating system kernel files. Table 1 describes the fields in the Partition Boot Sector for a volume formatted with the FAT file system.

Byte Offset

Field Length

Sample Value

Meaning

00 3 bytes EB 3C 90 Jump instruction
03 8 bytes MSDOS5.0 OEM Name in text
0B 25 bytes &nbry.

Return to top

The Partition Boot Sector

The Partition Boot Sector contains information that the file system uses to access the volume. On x86-based computers, the Master Boot Record use the Partition Boot Sector on the system partition to load the operating system kernel files. Table 1 describes the fields in the Partition Boot Sector for a volume formatted with the FAT file system.

Byte Offset

BIOS Parameter Block
24 26 bytes   Extended BIOS Parameter Block
3E 448 bytes   Bootstrap code
1FE 2 bytes 0x55AA End of sector marker

Table 1: fields in the Partition Boot Sector.

Return to top

BIOS Parameter Block and Extended BIOS Parameter Block

The BIOS Parameter Block, or BPB" is a structure that provides enough information for the executable portion of the boot sector to be able to locate the NTLDR file. Because the BPB always starts at the same offset, standard parameters are always in a known location. Because the first instruction in the boot sector is a jump, the BPB can be extended in the future, provided new information is appended to the end. Some additional fields follow the standard BIOS Parameter Block and constitute an "extended BIOS Parameter Block". Table 2 describes BIOS Parameter Block and Extended BIOS Parameter Block fields.

Byte Offset

Field Length

Sample Value

Meaning

0x0B

WORD

0x0002

Bytes per Sector. The size of a hardware sector. For most disks in use in the United States, the value of this field is 512.

0x0D

BYTE

0x08

Sectors Per Cluster. The number of sectors in a cluster. The default cluster size for a volume depends on the volume size and the file system.

0x0E

WORD

0x0100

Reserved Sectors. The number of sectors from the Partition Boot Sector to the start of the first file allocation table, including the Partition Boot Sector. The minimum value is 1. If the value is greater than 1, it means that the bootstrap code is too long to fit completely in the Partition Boot Sector.

0x10

BYTE

0x02

Number of file allocation tables (FATs). The number of copies of the file allocation table on the volume. Typically, the value of this field is 2.

0x11

WORD

0x0002

Root Entries. The total number of file name entries that can be stored in the root folder of the volume. One entry is always used as a Volume Label. Files with long filenames use up multiple entries per file. Therefore, the largest number of files in the root folder is typically 511, but you will run out of entries sooner if you use long filenames.

0x13

WORD

0x0000

Small Sectors. The number of sectors on the volume if the number fits in 16 bits (65535). For volumes larger than 65536 sectors, this field has a value of 0 and the Large Sectors field is used instead.

0x15

BYTE

0xF8

Media Type. Provides information about the media being used. A value of 0xF8 indicates a hard disk.

0x16

WORD

0xC900

Sectors per file allocation table (FAT). Number of sectors occupied by each of the file allocation tables on the volume. By using this information, together with the Number of FATs and Reserved Sectors, you can compute where the root folder begins. By using the number of entries in the root folder, you can also compute where the user data area of the volume begins.

0x18

WORD

0x3F00

Sectors per Track. The apparent disk geometry in use when the disk was low-level formatted.

0x1A

WORD

0x1000

Number of Heads. The apparent disk geometry in use when the disk was low-level formatted.

0x1C

DWORD

3F 00 00 00

Hidden Sectors. Same as the Relative Sector field in the Partition Table.

0x20

DWORD

51 42 06 00

Large Sectors. If the Small Sectors field is zero, this field contains the total number of sectors in the volume. If Small Sectors is nonzero, this field contains zero..

0x24

BYTE

0x80

Physical Disk Number. This is related to the BIOS physical disk number. Floppy drives are numbered starting with 0x00 for the A disk. Physical hard disks are numbered starting with 0x80. The value is typically 0x80 for hard disks, regardless of how many physical disk drives exist, because the value is only relevant if the device is the startup disk.

0x25

BYTE

0x00

Current Head. Not used by the FAT file system.

0x26

BYTE

0x29

Signature. Must be either 0x28 or 0x29 in order to be recognized by Windows NT.

0x27

4 bytes

CE 13 46 30

Volume Serial Number. A unique number that is created when you format the volume.

0x2B

11 bytes

NO NAME

Volume Label. This field was used to store the volume label, but the volume label is now stored as special file in the root directory.

0x36

8 bytes

FAT16

System ID. Either FAT12 or FAT16, depending on the format of the disk.

Table 2: fields in the BIOS Parameter Block and Extended BIOS Parameter Block.

Return to top

Volume Serial Number. A unique number that is created when you format the volume.

0x2B

11 bytes

NO NAME

Volume Label. This field was used to store the volume label, but the volume label is now stored as special file in the root directory.

0x36

8 bytes

FAT16

FAT Root Folder

The root folder contains an entry for each file and folder in the root. The only difference between the root folder and other folders is that the root folder is on a specified location on the disk and has a fixed size (512 entries for a hard disk, number of entries on a floppy disk depends on the size of the disk).

Return to top

Long File Names

One of the user experience goals for the designers of Windows 95 was the ability to use long filenames (LFNs, up to 255 UTF-16 code points long), in addition to classic 8.3 filenames (Short File Name, SFNs). For backward compatibility, LFNs were implemented as an optional extension on top of the existing FAT file system structures using a workaround in the way directory entries are laid out. This transparent method to store long file names in the existing FAT file systems without altering their data structures is usually known as VFAT (for "Virtual FAT"), after the Windows 95 virtual device driver. In Windows NT, support for VFAT long filenames started from version 3.5. Non VFAT-enabled operating systems can still access the files under their short file name alias without restrictions; however, the associated long file names may get lost, when files with long file names are copied under non VFAT-aware operating systems.

Return to top


Community Resources

Wiki Pages

TechNet Library Pages

Microsoft Knowledge Base Articles


See Also

NOTE: this section provides links that are external to the TechNet Wiki.

Books