disk organization

Complete

Summary

File block allocation

MethodCore IdeaAccess TypeStorage OverheadAdvantagesDisadvantages
contiguous allocationfile stored in consecutive blockssequential + randomminimal (start + length)- simple file tracking
- fast access
- external fragmentation
- hard to grow files
linked list allocationeach block points to the next blocksequentialpointer per block- no external fragmentation
- easy file growth
- slow random access
- pointer overhead
- reliability issues if pointer lost/incorrect
FAT allocationlinks stored in a central FATsequentialFAT- faster random access
- easier traversal
- FAT can be large
indexed allocationeach file has an index block containing pointers to all its blocksrandom + sequentialindex block per file- fast direct access
- less memory overhead, only index block of opened file needs to be in memory
- index block overhead
- waste for small files
- multi-level index for large files

Concept

  • disk - 1D array of logical blocks
  • logical blocks are mapped into disk sectors

Master Boot Record(MBR)

  • at sector 0
  • has a partition table
  • followed by one or more partitions
  • contains:
    • OS boot-up info

Partition

  • contain the actual files
  • contains:
    • partition details - number of blocks
    • directory structure
    • file info
    • file data

disk_org.png

Allocating files

  • files are a set of logical blocks
  • implementation needs to:
    • keep track of logical blocks
    • allow efficient access
    • effectively use disk space
  • using fixed blocks -> always has internal fragmentation

Contiguous allocation

  • allocate consecutive blocks to each file
  • file info stores first block and size

contiguous_allocation.png