File Allocation Methods — Contiguous, Linked & Indexed
The Problem — 100,000 Lockers
Those are exactly the three file allocation methods: contiguous (a consecutive run), linked (a chain of pointers), and indexed (one index block listing all the data blocks). Each trades speed against flexibility — and, as we'll see, against how a disk survives an attack.
Three Classical Families
Every method answers the same question — "given a file and a block number, which physical disk block do I read?" — differently. The rest of this tutorial traces that lookup through each design and counts the disk seeks it costs.
Contiguous — One Run Per File
Each file is a consecutive run, so the directory needs only a start block and a length: count at 2 (len 3), mail at 10 (len 6), list at 19 (len 4). Block k of a file is simply start + k — one seek to reach any byte.
Contiguous — The Trade-offs
# Reach block k of a contiguous file — one calculation, one seek physical_block = start + k # e.g. start=100, k=2 → block 102
Because a file's blocks sit together, investigators can carve a deleted file straight off the raw disk by scanning for its signature bytes — no directory needed. Tools like PhotoRec and Autopsy lean on exactly this property.
Linked — A Chain of Pointers
The directory records only the start block (9); every block then stores the address of the next, ending at NULL. Files grow by appending a block anywhere free — no external fragmentation. But reaching block k means walking k+1 blocks, and one corrupt pointer orphans the entire tail.
FAT — Pull the Pointers Into a Table
Storing the "next" pointer inside each block wastes space and forces a seek per hop. The File Allocation Table gathers every pointer into one table the OS caches in RAM.
# Pointer overhead in a classic 512-byte block 4 bytes pointer + 508 bytes data = 512-byte block # ~0.8% overhead
FAT debuted with MS-DOS (1981) and carried Windows 95/98/ME. Caching the whole table in memory turns chain-walking into fast in-RAM lookups. Its descendants — FAT32 and exFAT — still format nearly every USB stick, SD card and camera today.
Indexed — One Block Lists Them All
One index block (here block 19) holds an array of every data-block address — [9, 16, 1, 10, 25, −1]. To read block k, look up index[k] and seek there: fast random access and easy growth, at the cost of one index block per file.
The UNIX i-node — Indexing That Scales
The i-node's 12 direct pointers reach a 48 KB file in one seek — most files are small, so this is the common case. Single, double and triple indirect pointers add index-of-index levels, scaling to 4 MB, 4 GB and 4 TB. Tiny files pay nothing for the machinery big files need.
Reading Byte 10,240 — Count the Seeks
| Method | How block 2 is found | Seeks |
|---|---|---|
| Contiguous | start 100 + 2 = block 102 | 1 seek |
| Indexed | read index block, then index[2] | 2 seeks |
| Linked | walk block 0 → 1 → 2 in the chain | k+1 = 3 seeks |
Every method first splits the offset into block 2, offset 2,048. From there contiguous needs one seek, indexed a fixed two, and linked k+1 — growing with the block number. That single difference is why random-access workloads avoid linked allocation.
The Three Methods, Side by Side
| Property | Contiguous | Linked | Indexed |
|---|---|---|---|
| Sequential access | Excellent | Good | Good |
| Random access | Excellent | Poor | Good |
| External fragmentation | Yes | None | None |
| Internal fragmentation | Minimal | Minimal | Small |
| File growth | Painful | Easy | Easy |
| Overhead per file | None | 1 ptr / block | 1 index / file |
| Fault tolerance | Medium | Very low | Low |
| Real-world use | CD-ROM / DVD | FAT32 / exFAT | ext2/3/4 |
Contiguous wins on read-only media; linked survives fragmentation but crawls on random access; indexed balances both and powers modern Linux file systems. The right choice depends on the workload and the medium.
When Allocation Meets Attackers
Forensics — Reading the Disk Directly
FF D8 FF, PDF %PDF- — to recover deleted files.
NTFS Alternate Data Streams let extra hidden streams ride along with a file — a classic malware
hiding spot, surfaced with dir /R or streams.exe. Journaling ($LogFile, ext4 journal) both
protects integrity and leaves a trail investigators can follow.
Eight Rules for File Allocation
Where a File's Blocks Live
From contiguous runs, linked chains and index blocks, through the UNIX i-node and seek-cost maths, to the security cases where destroying an index destroys access — you can map any file to its physical blocks and reason about how a disk survives failure and attack.
Allocation decides where blocks go; next comes free-space management (bitmaps and free lists) and disk scheduling (FCFS, SSTF, SCAN, C-SCAN) — how the OS chooses which pending disk request to serve first.
🗂️ End of tutorial · Press ← to review, or click Restart