File Allocation Methods: Contiguous
You'll learn: How contiguous allocation stores files in consecutive disk blocks and why fragmentation becomes a critical problem.
What is Contiguous Allocation?
Contiguous allocation is the simplest file allocation strategy where each file occupies a consecutive sequence of disk blocks. Think of it like reserving a row of adjacent seats at a movie theater—your group sits together in seats 15, 16, 17, 18, all in one unbroken line.
When the file system creates a file, it needs just two pieces of metadata:
- Starting block address (where the file begins)
- Length (how many consecutive blocks it occupies)
For example, if report.txt starts at block 200 and is 5 blocks long, it occupies blocks 200–204.
Advantages
Fast sequential access: Reading the entire file is blazingly fast because the disk head moves smoothly across consecutive blocks without seeking elsewhere.
Simple addressing: Finding any byte requires minimal calculation—just offset from the starting block.
The Fragmentation Problem
Here's the critical issue: external fragmentation. As files are created and deleted, the disk develops "holes"—free blocks scattered throughout. You might have 100 free blocks total, but they're not consecutive. If a user tries to save a 50-block file, it fails despite having enough total space!
Imagine that theater again: 20 scattered empty seats exist, but your party of 10 needs to sit together—you can't be seated.
Solutions like compaction (rearranging files to consolidate free space) are expensive and cause downtime. Allocating extra space upfront wastes storage if files don't grow as expected.
Key Takeaway: Contiguous allocation provides excellent sequential performance through consecutive disk block storage, but suffers from severe external fragmentation as files are created and deleted over time.