How MS-DOS 6.22 Manages FAT Non-Contiguous Sectors

MS-DOS 6.22 manages non-contiguous data allocations on FAT volumes by abstracting raw disk sectors into clusters and tracking file fragmentation using a linked-list structure recorded directly in the File Allocation Table (FAT). Instead of requiring files to occupy sequential physical storage, the operating system links scattered clusters together via index pointers, allowing files to be read and written across separated regions of a disk seamlessly.

The Role of Clusters and Sector Grouping

In MS-DOS 6.22, storage devices are formatted using either the FAT12 or FAT16 file system architecture. MS-DOS does not assign individual 512-byte sectors to files directly. Instead, it groups contiguous sectors into single allocation units known as clusters. A cluster size typically ranges from 1 sector (512 bytes) on small floppy disks up to 64 sectors (32 KB) on larger hard disk partitions. All allocation tracking, contiguous or non-contiguous, takes place at the cluster level.

The Directory Entry and FAT Linked List

When a file becomes fragmented—meaning its clusters are not physically adjacent on the disk—MS-DOS 6.22 tracks its location using two primary components: the directory entry and the FAT table itself.

  1. The Starting Cluster: The file's directory entry stores critical metadata, including the file name, size, attributes, timestamps, and a 16-bit field containing the address of the file's starting cluster.
  2. Cluster Chaining: The File Allocation Table is an array where each entry corresponds directly to a physical cluster on the disk. To read a non-contiguous file, MS-DOS reads the starting cluster entry from the directory, accesses that index in the FAT, and reads the value stored there.
  3. Next-Cluster Pointers: If the file spans multiple non-contiguous areas, the value held inside the FAT entry is the integer index of the next cluster allocated to that file. MS-DOS follows these entries sequentially, traversing the chain until it reaches a designated End-of-Cluster (EOF) marker (typically values ranging from 0xFFF8 to 0xFFFF in FAT16).

Allocation Behavior and Fragmentation

When MS-DOS 6.22 creates or expands a file, it searches the FAT for entries marked as free (0x0000). Under standard write operations, the operating system employs a "first fit" or "next fit" strategy:

  • It scans the FAT linearly for the first available unallocated cluster.
  • If a file requires more space than the size of the discovered free block, MS-DOS allocates all available clusters in that contiguous block, marks the final cluster to point to the next free cluster found further down the table, and continues writing.
  • This behavior inherently produces non-contiguous allocations over time as files of varying sizes are created, expanded, and deleted.

Translating Clusters to Physical Sectors

To execute physical read and write operations via BIOS interrupts (INT 13h), the MS-DOS kernel translates non-contiguous cluster chains into absolute sector addresses. The system calculates the physical sector number using the cluster number, the sectors-per-cluster value defined in the BIOS Parameter Block (BPB), and the reserved offset sectors (boot sector, FAT copies, and root directory).

Because non-contiguous clusters cannot be read in a single contiguous multi-sector I/O operation, MS-DOS breaks read and write routines into separate operations per contiguous segment, adjusting the disk head position across the platters as it follows the FAT pointers.