Contiguous Allocation
Best for Read-Only
Read aloud is unavailable in this browser.
Where Contiguous Allocation Shines
Despite the fragmentation challenges we've explored, contiguous allocation remains the optimal choice for specific scenarios. When files never change after creation, fragmentation never develops—and the performance advantages become pure benefit with no downside.
This page explores the real-world applications where contiguous allocation delivers its full potential: read-only media, archival systems, and performance-critical static workloads.
By the end of this page, you'll understand the ideal use cases for contiguous allocation, how read-only media exploits its strengths, and how modern systems use contiguous allocation selectively for optimal performance.
Read-Only Media: The Perfect Fit
CD-ROM, DVD, and Blu-ray discs use contiguous allocation almost universally. Here's why it's perfect:
No Fragmentation Possible:
- Files are written once during mastering
- No deletions or modifications ever occur
- Allocation can be optimized at creation time
- Files are packed with zero wasted space
Why Contiguous Matters for Optical Media:
- Optical drives read best at constant angular velocity
- Seeking (moving the laser) is slow (~100-200ms)
- Sequential reading is dramatically faster than random
- Streaming video/audio demands predictable throughput
| Media Type | File System | Block Size | Use Case |
|---|---|---|---|
| CD-ROM | ISO 9660 | 2 KB | Software distribution, music |
| DVD-ROM | UDF | 2 KB | Movies, games, data archives |
| Blu-ray | UDF 2.50+ | 2 KB | HD/4K video, large datasets |
| Audio CD | Red Book | 2352 bytes | Music (raw audio frames) |
The ISO 9660 file system standard for CD-ROMs was designed with contiguous allocation from the start. Each directory entry contains a Location (starting block) and Data Length—exactly the contiguous allocation model. The standard assumes files are written once and read many times.
Installation and Distribution Media
OS installers and software distribution benefit enormously from contiguous allocation:
Installation Media Characteristics:
- Created once, read many times
- Speed of installation matters to users
- Sequential reading of large files (disk images, packages)
- No modification after creation
Performance Impact:
| File Type | Size | Contiguous Read | Fragmented Read |
|---|---|---|---|
| Windows ISO | 5 GB | ~50 seconds | ~5 minutes |
| Package Archives | 500 MB | ~5 seconds | ~30 seconds |
| Database Dump | 10 GB | ~100 seconds | ~10 minutes |
USB Boot Drives:
Even USB-based installation media uses contiguous allocation for the boot image. Tools like Rufus and dd create contiguous disk images because:
- Boot loaders expect contiguous sectors
- BIOS/UEFI reads sequentially during boot
- Installation speed is user-visible
Archival and Backup Systems
Long-term data storage systems favor contiguous allocation for its simplicity and reliability:
- •Data Integrity: Simpler format means fewer corruption risks
- •Longevity: Less metadata complexity = easier recovery decades later
- •Streaming Restore: Sequential read for fastest restore times
- •Verification: Simple structure enables easy integrity checking
- •Tool Compatibility: Wide support across platforms and decades
Tape Storage:
Magnetic tape—still used for cold storage in enterprises—is inherently sequential. Contiguous allocation aligns perfectly with tape's sequential nature, where seeking is measured in seconds, not milliseconds.
Swap Files and System Areas
Operating systems use contiguous allocation for performance-critical system areas:
Swap Space/Page Files:
- Windows: pagefile.sys is contiguous when possible
- Linux: Swap partitions are inherently contiguous
- macOS: Swap files use contiguous extents
Why Swap Must Be Fast:
- Swap occurs under memory pressure (system already stressed)
- Page faults block processes until resolved
- Random swap access causes severe thrashing
- Contiguous swap enables prefetching
123456789101112131415161718192021222324252627282930313233343536
/* * Swap Space Allocation Strategy * * Swap should be contiguous for maximum performance * during memory pressure situations. */ typedef struct { uint64_t start_sector; uint64_t sector_count; uint64_t pages_per_sector;} swap_area_t; /* Allocate contiguous swap area */bool allocate_swap_area(swap_area_t *swap, uint64_t size_mb) { uint64_t sectors_needed = (size_mb * 1024 * 1024) / 512; /* Must find contiguous region */ swap->start_sector = find_contiguous_sectors(sectors_needed); if (swap->start_sector == INVALID_SECTOR) { /* Cannot create fragmented swap - too slow */ return false; } swap->sector_count = sectors_needed; swap->pages_per_sector = 512 / PAGE_SIZE; /* Usually 8 */ return true;} /* O(1) page address calculation - contiguous benefit */uint64_t swap_page_to_sector(swap_area_t *swap, uint32_t page_num) { return swap->start_sector + (page_num / swap->pages_per_sector);}Database Tablespaces and Large Files
Databases often pre-allocate contiguous storage for tables and indexes:
Why Databases Prefer Contiguous:
- Full table scans read sequentially
- Index range scans access adjacent pages
- Write-ahead logs append sequentially
- Pre-allocation avoids runtime fragmentation
Modern Database Approach:
- •Oracle: Datafiles are pre-allocated and extended in contiguous extents
- •PostgreSQL: Uses file system but benefits from contiguous allocation
- •MySQL/InnoDB: Tablespace files pre-allocated for contiguous access
- •SQLite: Single file, benefits from being contiguous on disk
Databases pre-allocate storage in large chunks (e.g., 100 MB extents) on an empty disk before data is written. This ensures contiguous allocation even on file systems that otherwise fragment.
Modern Relevance: Extents and Hybrid Approaches
Modern file systems don't use pure contiguous allocation, but they incorporate its principles through extents—contiguous runs of blocks that form part of a file.
Extent-Based Allocation:
- Each file = sequence of extents (contiguous regions)
- Small files: single extent (fully contiguous)
- Large/fragmented files: multiple extents
- Best of both worlds: contiguous when possible, flexible when needed
File Systems Using Extents:
| File System | Extent Support | Max Extent Size |
|---|---|---|
| ext4 | Yes (default) | 128 MB |
| XFS | Yes (native) | 8 EB theoretically |
| Btrfs | Yes | Variable |
| NTFS | Yes (runs) | 16 TB |
| APFS | Yes | Variable |
The Extent Advantage:
Extent-based systems try to allocate files contiguously but gracefully handle fragmentation when it occurs. A 1 GB file on ext4 might be:
- Ideal: 1 extent of 256,000 blocks
- Acceptable: 4 extents of ~64,000 blocks each
- Fragmented: 1000+ small extents (rare, indicates problems)
Summary: Best for Read-Only
- •Read-only media (CD/DVD/Blu-ray) uses contiguous allocation exclusively—optimal for write-once, read-many scenarios.
- •Installation media benefits from contiguous layout for maximum installation speed.
- •Archival systems prefer simplicity and sequential restore capability.
- •Swap/page files are allocated contiguously for performance under memory pressure.
- •Databases pre-allocate contiguous storage for sequential scan performance.
- •Modern file systems use extent-based hybrid approaches—contiguous when possible, flexible when needed.
You have completed the Contiguous Allocation module! You now understand how contiguous allocation works, its exceptional sequential performance, the challenge of external fragmentation, the costs of compaction, and where this allocation strategy remains optimal. Next, explore Linked Allocation to see how file systems overcome contiguous allocation's limitations.
KEEP LEARNING
Keep learning for free.
Read the complete lesson, save your notes and pick up where you left off with a free account. No card needed.