Skip to content
CurriculumLesson 29 · Files
Advanced~14 min

Indexed File Allocation

Indexed allocation puts every block pointer in one index block. Direct access becomes fast, at the cost of an extra block and a limit on file size.

In plain English

Indexed allocation is a table of contents that points to every block of the file.

By the end you will be able to

  • Explain an index block and its pointers.
  • Compute direct-access cost.
  • Know how multi-level indexes extend file size.
  • Compare indexed allocation with FAT.
01

The index block

The directory entry points to an index block. The index block contains pointers to the file's data blocks. To read file block i, load the index block and follow pointer i. The data block need not be read to find the next block. This gives direct access in two reads: index block plus data block.

lesson-29.osOS
directory: report.txt -> index block 3
index[0] = 7
index[1] = 11
index[2] = 18
index[3] = 21

read file block 2 -> read index[2] -> read block 18
02

Multi-level indexes

A single index block limits the maximum file size. A multi-level index uses an index of indexes. The first-level block points to second-level index blocks, which point to data blocks. This scales to large files but adds memory accesses for deep lookups. Real file systems blend direct, indirect, and multi-level pointers.

03

Trade-offs

Indexed allocation gives fast direct access and no external fragmentation. It wastes space when a file is small because the index block is mostly empty, and it adds an extra block read per access. FAT is better for tiny files and sequential scans; indexed allocation is better for random access and larger files.

Watch it happen

Step through the worked example. Play it, pause it, or move one step at a time.

step-by-step

Step 1 of 4

Directory entry points to the index block

The file's directory entry stores index block 3.

report.txt → index block 3
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

Key takeaways

  • An index block stores pointers to data blocks.
  • Direct access costs index read plus data read.
  • Multi-level indexes extend the maximum file size.
  • Indexed allocation avoids chain traversal.
  • The index block can waste space for small files.

Common pitfalls

  • Forgetting the index block read in the access cost.
  • Assuming one index block can address unlimited file size.
  • Confusing an index block with a data block.

Kernel notes

  • Trace a direct read through an index block.
  • Explain multi-level indexing.
  • Compare FAT and indexed access costs.

Quick check

0 / 2 answered

1. What does an index block contain?

2. What is the direct-access cost for indexed allocation?