7.3UNIX inode and maximum file size
The idea
A UNIX inode stores a file's attributes and block pointers: a few direct ones plus single, double and triple indirect blocks.
Think of it like this: A tiny contents page for small books, and for bigger ones the page points to a page of pointers, then to a page of pages of pointers.
Why it exists
Small files stay fast, and the structure still reaches enormous sizes. The maximum file size is a classic numerical.
How it works
- Pointers per block = block size / pointer size.
- Direct: d × B. Single indirect: (B/P) × B. Double: (B/P)² × B. Triple: (B/P)³ × B.
- Add the levels that exist.
- A byte in the double-indirect region costs 2 index reads plus the data block.
Worked example: B = 1 KB, P = 4 bytes, 12 direct pointers
B/P = 256. Direct 12 KB, single 256 KB, double 64 MB, triple 16 GB. Maximum ≈ 16 GB + 64 MB + 256 KB + 12 KB.
Now play with it
- →Use the calculator, change the block size to 4 KB and read the new maximum.
- →Remove the triple level in your head: which term disappears?
With 1 KB blocks and 4-byte pointers the triple-indirect level alone is 16 GB. To read a byte in the triple-indirect region costs 3 index-block reads plus the data block.
Check yourself
In an inode scheme with 8 KB blocks and 4-byte pointers, one indirect block can address
Exam notes (the dense version)
An inode holds the file's attributes and block pointers: typically d direct pointers, one single-indirect, one double-indirect and one triple-indirect pointer. With block size B and pointer size P a block holds B / P pointers. Maximum file size = (d + (B/P) + (B/P)² + (B/P)³) × B. The directory entry holds only the name and inode number, so renaming never copies the data. Small files use only the direct pointers (fast); the blocks reached through indirection cost extra disk accesses.
Previous year questions: File Systems (5)
PYQs are grouped by topic, so this is the full set for File Systems; try the ones that match this subtopic. Open all 5 on the topic page.