Format:FAT (FAT12, FAT16, FAT32, VFAT)
| On this wiki | Facts · Code · Notes · Topics |
|---|
The File Allocation Table filesystem of DOS, Windows, SD cards, UEFI system partitions and many embedded devices: a BPB in the boot sector, one or two FATs, 32-byte directory entries with 8.3 names and VFAT long-name slots. FAT12, FAT16 and FAT32 differ in entry width, and the type follows from the cluster count, not from the label string.
Overview
A FAT volume starts with a boot sector holding the BIOS Parameter Block (BPB), then reserved sectors, one or two copies of the File Allocation Table, (FAT12/16 only) a fixed root directory, and the data area of clusters numbered from 2. Each FAT entry gives the next cluster of a chain; the entry width (12, 16 or 28 used bits of 32) names the variant. The same 0x55 0xAA signature ends the boot sector of NTFS and exFAT too, so identify by the fields below (see Format:MBR partition table for partition type ids 0x01/0x04/0x06/0x0B/0x0C/0x0E).
Boot sector (BPB)
Layout as the Linux driver declares it (struct fat_boot_sector, offsets computed from the declaration): jump 0x00 (3 bytes), OEM name 0x03 (8), bytes per sector 0x0B (16-bit, unaligned), sectors per cluster 0x0D, reserved sectors 0x0E, number of FATs 0x10, root entries 0x11 (16-bit), total sectors 16-bit 0x13, media 0x15, sectors per FAT (16-bit) 0x16, sectors per track 0x18, heads 0x1A, hidden sectors 0x1C, total sectors 32-bit 0x20.
- FAT12/16 extension: drive number 0x24, state byte 0x25 (bit 0 = dirty), extended signature 0x26, volume id 0x27, label 0x2B (11), type string 0x36 (8).
- FAT32 extension: sectors per FAT (32-bit) 0x24, flags 0x28, version 0x2A, root directory cluster 0x2C, FSInfo sector 0x30, backup boot sector 0x32, then drive number 0x40, state 0x41, extended signature 0x42, volume id 0x43, label 0x47, type string 0x52. The Linux driver accepts only power-of-two sector sizes from 512 to 4096.
How the type is decided
The type string ("FAT12 ", "FAT32 ") is informational. Linux treats the volume as FAT32 when the 16-bit sectors-per-FAT field is 0 and the 32-bit one is not; otherwise it counts data clusters, (total sectors minus data start) divided by sectors per cluster, and uses FAT16 if the count exceeds 0xFF4 (4084), else FAT12. The reserved cluster values are the same idea at each width: bad 0xFF7 / 0xFFF7 / 0x0FFFFFF7, end-of-chain 0xFFF / 0xFFFF / 0x0FFFFFFF, first data cluster 2.
FAT32 FSInfo sector
The sector named by the BPB holds signature 0x41615252 (bytes 52 52 61 41, "RRaA") at 0, signature 0x61417272 (bytes 72 72 41 61, "rrAa") at 484, the free-cluster count at 488 (-1 if unknown) and the most recently allocated cluster at 492. Both counts are hints only and are often stale; recompute from the FAT when carving.
Directory entries
32 bytes each: name+extension 0 (11 bytes, space padded), attributes 0x0B, case flags 0x0C (8 = base lower case, 16 = extension lower case), creation time in 10 ms units 0x0D, creation time 0x0E, creation date 0x10, access date 0x12, high 16 bits of the first cluster 0x14 (FAT32), write time 0x16, write date 0x18, low first cluster 0x1A, size 0x1C. First byte 0x00 = free and no entries follow in practice; 0xE5 = deleted (the first character is lost, so recovery needs a guess). Attribute bits: 0x01 read-only, 0x02 hidden, 0x04 system, 0x08 volume label, 0x10 directory, 0x20 archive; the combination 0x0F (read-only|hidden|system|volume) marks a long-name slot.
Long file names (VFAT)
A name that does not fit 8.3 is stored in up to 20 slots placed just before the short entry, in reverse order. Each slot: sequence number 0 (bits 0-5; bit 0x40 marks the slot that is logically last and physically first), 5 UTF-16LE characters at 1, attribute 0x0F at 0x0B, a zero type byte at 0x0C, checksum of the 11-byte short name at 0x0D, 6 characters at 0x0E, a zero cluster at 0x1A, 2 characters at 0x1C: 13 characters per slot, 255 at most. The checksum rotates right by one and adds each byte of the 11-byte name; a reader must discard the long name when it does not match the short entry that follows, which happens after an old OS edits the short name.
Analyst notes
- Cluster 0 and 1 map to the media byte and a dirty flag; data starts at cluster 2.
- FAT12 packs two entries into three bytes; entry n is at byte offset n + n/2. Unverified: read from memory, not in the sources cited here.
- exFAT is a different filesystem with the same 0x55AA tail: Format:exFAT.
Sources
Linux fs/fat and include/uapi/linux/msdos_fs.h at c03c1a14 (GPL-2.0). Microsoft's FAT specification was not read for this page.
Code & repositories
- https://github.com/torvalds/linux @
c03c1a14507dfaf8b856c2608f9ac216021fc222· license: GPL-2.0-only WITH Linux-syscall-note (declared by the contributor for the files used; GitHub reports GPL-2.0 WITH Linux-syscall-note (read from COPYING; GitHub's detector did not classify it) for the repository)
Linux kernel; fs/fat, include/uapi/linux/msdos_fs.h and fs/exfat/exfat_raw.h are the on-disk structure declarations used here.
Tested on: source read, not run: source read only · checked 2026-10-19; last activity 2026-10-18