Jump to content

6.4.2 File Allocation Methods

From Computer Science Knowledge Base

6.4.2 File Allocation Methods

(Difficulty Note: This is an internal technical detail of how files are physically stored.)

When you save a file, the OS needs to figure out where on the hard drive to put it. Hard drives are like big, empty grids of storage blocks. The file allocation method is the strategy the OS uses to find and keep track of these blocks for each file.

Imagine you have a long story to write, but you only have small sticky notes (storage blocks). How do you keep track of which sticky note comes next?

  • Contiguous Allocation: The OS tries to find one big, continuous block of space on the hard drive for the entire file. This is fast to read, but it can be hard to find big enough empty spaces as the drive fills up, and if a file grows, it might need to be moved. (Like keeping all your story notes on one long piece of paper.)
  • Linked Allocation: The file is broken into many small pieces (blocks) that can be stored anywhere on the hard drive. Each block has a pointer (like an arrow) that tells the OS where the next piece of the file is located. This is flexible, but it's slower to find a specific part of a file because the OS has to follow all the pointers. (Like each sticky note having an arrow to the next one.)
  • Indexed Allocation: The OS creates a special "index block" (like a table of contents) for each file. This index block lists all the locations of all the pieces of the file. This is efficient for finding any part of a file quickly. (Like having a master list that tells you exactly which sticky note is where.)

These methods ensure that even though files might be scattered across your hard drive, the OS can always find and put them back together correctly when you open them.

Bibliography: