The FAT16 File System: Fragmentation 16-Bit

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

The FAT16 file system

The first file system to be used on a Microsoft operating system was the FAT system, which uses a file
allocation table. The file allocation table is actually an index which lists the content of the disk in order to
record the location of the files on it. Since the blocks making up a file are not always stored contiguously
on the disk (a phenomenon called fragmentation), the allocation table allows the file system structure to
be maintained by creating links to the blocks making up the file. The FAT system is a 16-bit system that
allows files to be identified by a name consisting of up to 8 characters and a 3 character extension, which
is why this system is called FAT16.
To improve on this, the original version of Windows 95 (using the FAT16 system) was delivered with
improved FAT management in the form of the VFAT (Virtual FAT) system. VFAT is a 32-bit system that
allows file names of up to 255 characters in length. The programmers had to ensure forward compatibility,
however, so that 16-bit (DOS) environments could still access these files. The solution was therefore to
assign one name for each system. This is why it is possible to use long file names under Windows 95, but
still access them under DOS.
The FAT file system is a 16-bit system, which means that cluster addresses can not be bigger than 16
bits. The maximum number of clusters that can be referenced with the FAT system is therefore 2 16,
(65536) clusters. Now, since a cluster consists of a fixed number (4,8,16,32, ...) of sectors of 512
contiguous bytes, the maximum size of FAT partition can be determined by multiplying the number of
clusters by the size of a cluster. With 32Kb clusters, the maximum size of a FAT partition is therefore
2GB.
Furthermore, a file can only occupy an integral number of clusters, which means that if a file occupies
several clusters, the last cluster will only be partially occupied and the unoccupied space will be unusable.
As a result, the smaller the cluster size, the less wasted space. It is estimated that a file wastes, on
average, half a cluster, which means that on a 2 GB partition, 16KB will be lost per file…
The file allocation table
The File Allocation Table is a list of digital values that describes the allocation of the clusters of a partition
or, in other words, the state of each cluster of the partition in which it is located. In fact, each cell of the
allocation table corresponds to a cluster. Each cell contains a number that indicates if the cluster is used
by a file and, if so, the location of the next cluster in the file. In this way, you end up with a FAT chain, a
linked list of references pointing to the successive clusters up until the end of the file. Each FAT entry is
16- or 32-bits long (depending on whether it is FAT16 or FAT32). The first two entries store information
about the table itself, while the following entries reference the clusters. Certain entries may contain values
indicating the state of the specific cluster. For example, the value 0000 indicates that the cluster is not
used, FFF7 marks the cluster as bad so that it will not be used, and values between FFF8 and FFFF
specify that the cluster contains the end of a file. Each partition actually contains two copies of the table
stored contiguously on the disk, so that it can be recovered if the first copy becomes corrupted.
The FAT32 file system
Although VFAT was a clever system, it did not address the limitations of FAT16. As a result, a new file
system (and not just better FAT management as was the case with VFAT) appeared with Windows 95
OSR2. This file system, called FAT32 uses 32-bit values for the FAT entries. In fact, only 28 bits are
used, as 4 bits are reserved for future use.
With the appearance of the FAT32 file system, the maximum number of clusters per partition went
increased from 65535 to 268,435,455 (228-1). FAT32 thus allows much bigger partitions (up to 8
terabytes). Although the maximum theoretical size of a FAT32 partition is 8 TB, Microsoft has voluntarily
limited it to 32 GB on Windows 9x systems to promote NTFS (ref:
http://support.microsoft.com/default.aspx?scid=kb;fr;184006). Since a FAT32 partition can contain many
more clusters than a FAT16 partition, it is possible to reduce significantly the size of the clusters and
thereby also limit wasted disk space. For example, with a 2GB partition, it is possible to use 4KB clusters
with the FAT32 system (instead of 32KB clusters with FAT16), which reduces the wasted space by a
factor of 8.
The trade-off for this is that FAT32 is not compatible with Windows versions prior to OEM Service
Release 2. A system booting up with an earlier version will simply not see this type of partition.
Also, 16-bit disk management utilities, such as early versions of Norton Utilities, will no longer work
correctly. In terms of performance, using a FAT32 system instead of a FAT16 system will result in a slight
performance improvement on the order of 5%.
FAT16 or FAT32 file system?
As the number of clusters is limited, the maximum size of a partition depends on the size of each cluster.
Let's take a look at the maximum partition size according to the cluster size and file system used:
FAT32 file system
FAT16 file
Cluster size
system
(theoretical)

512 bytes 32 MB 64 MB

1 KB 64 MB 128 MB

2 KB 128 MB 256 MB

8 GB
4 KB 256 MB
(1 TB)

16 GB
8 KB 512 MB
(2 TB)

32 GB
16 KB 1 GB
(4 TB)

2 GB
32 KB 2 GB
(8 TB)

When you format a hard disk, you therefore need to decide carefully on the type of file system to use, and
select the one that provides an amount of available space that is as close as possible to the desired size!

File Allocation Table

A partition is divided up into identically sized clusters, small blocks of contiguous space. Cluster
sizes vary depending on the type of FAT file system being used and the size of the partition,
typically cluster sizes lie somewhere between 2 KB and 32 KB. Each file may occupy one or
more of these clusters depending on its size; thus, a file is represented by a chain of these clusters
(referred to as a singly linked list). However these clusters are not necessarily stored adjacent to
one another on the disk's surface but are often instead fragmented throughout the Data Region.

The File Allocation Table (FAT) is a list of entries that map to each cluster on the partition.
Each entry records one of five things:

 the cluster number of the next cluster in a chain


 a special end of clusterchain (EOC) entry that indicates the end of a chain
 a special entry to mark a bad cluster
 a special entry to mark a reserved cluster[citation needed]
 a zero to note that the cluster is unused
Each version of the FAT file system uses a different size for FAT entries. Smaller numbers result
in a smaller FAT table, but waste space in large partitions by needing to allocate in large clusters.
The FAT12 file system uses 12 bits per FAT entry, thus two entries span 3 bytes. It is
consistently little-endian: if you consider the 3 bytes as one little-endian 24-bit number, the 12
lsbits are the first entry and the 12 msbits are the second.

In the FAT32 file system, FAT entries are 32 bits, but only 28 of these are actually used; the 4
msbits are reserved.

FAT entry values:

FAT12 FAT16 FAT32 Description

0x000 0x0000 0x00000000 Free Cluster

0x001 0x0001 0x00000001 Reserved value; do not use

0x002– 0x0002– 0x00000002–


Used cluster; value points to next cluster
0xFEF 0xFFEF 0x0FFFFFEF

0xFF0– 0xFFF0– 0x0FFFFFF0–


Reserved values; do not use[27].
0xFF6 0xFFF6 0x0FFFFFF6

0xFF7 0xFFF7 0x0FFFFFF7 Bad sector in cluster or reserved cluster

0xFF8– 0xFFF8– 0x0FFFFFF8–


Last cluster in file
0xFFF 0xFFFF 0x0FFFFFFF

Note that FAT32 uses only 28 bits of the 32 possible bits. The upper 4 bits are usually zero (as
indicated in the table above) but are reserved and should be left untouched.

The first cluster of the Data Region is cluster #2. That leaves the first two entries of the FAT
unused. In the first byte of the first entry a copy of the media descriptor is stored. The remaining
8 bits (if FAT16), or 20 bits (if FAT32) of this entry are 1. In the second entry the end-of-cluster-
chain marker is stored. The high order two bits of the second entry are sometimes, in the case of
FAT16 and FAT32, used for dirty volume management: high order bit 1: last shutdown was
clean; next highest bit 1: during the previous mount no disk I/O errors were detected

FAT32 Features

FAT32 provides the following enhancements over previous implementations of the FAT file system:
 FAT32 supports drives up to 2 terabytes in size.

NOTE: Microsoft Windows 2000 only supports FAT32 partitions up to a size of 32 GB.

 FAT32 uses space more efficiently. FAT32 uses smaller clusters (that is, 4-KB clusters for drives

up to 8 GB in size), resulting in 10 to 15 percent more efficient use of disk space relative to

large FAT or FAT16 drives.

 FAT32 is more robust. FAT32 can relocate the root folder and use the backup copy of the file

allocation table instead of the default copy. In addition, the boot record on FAT32 drives is

expanded to include a backup copy of critical data structures. Therefore, FAT32 drives are less

susceptible to a single point of failure than existing FAT16 drives.

 FAT32 is more flexible. The root folder on a FAT32 drive is an ordinary cluster chain, so it can

be located anywhere on the drive. The previous limitations on the number of root folder entries

no longer exist. In addition, file allocation table mirroring can be disabled, allowing a copy of

the file allocation table other than the first one to be active. These features allow for dynamic

resizing of FAT32 partitions. Note, however, that although the FAT32 design allows for this

capability, it will not be implemented by Microsoft in the initial release.

You might also like