Unix Inodes & File Allocation Methods
“Calculating maximum file sizes with direct, single, double, and triple indirect pointers.”
1.The Inode Architecture in Unix File Systems
§ 8.1.In the classical Unix textbook model, a file's metadata and disk block pointers are stored in an Index Node (inode). Modern file systems may use different structures; for example, ext4 commonly uses extents rather than the exact textbook pointer array described below.
An inode contains file attributes (size, owner, permissions, timestamps) and references to the file's data blocks. In the classical model used for the calculation below, it contains 15 block pointers:
• 12 Direct Pointers: Point directly to data blocks storing the file's contents.
• 1 Single Indirect Pointer: Points to an index block containing pointers to data blocks.
• 1 Double Indirect Pointer: Points to an index block that contains pointers to index blocks, which in turn point to data blocks.
• 1 Triple Indirect Pointer: Points to an index block pointing to double indirect blocks.
File allocation methods: Contiguous allocation stores a file in adjacent blocks and gives fast sequential access, but suffers from external fragmentation. Linked allocation follows a pointer chain and eliminates external fragmentation, but random access is slow (O(N)). Indexed allocation stores block addresses in an index block, supporting direct access at the cost of index overhead. The inode's direct and indirect pointers are a Unix-style indexed allocation design.
2. Worked Calculation: Maximum File Size
| Block Size4 KB = 4096 bytes | Block Pointer Size4 bytes | Pointers per Block4096 / 4 = 1024 = 2^10 pointers |
12 direct pointers point to 12 data blocks.
One pointer points to a block containing 1024 pointers.
1024 * 1024 = 2^20 pointers to data blocks.
1024 1024 1024 = 2^30 pointers to data blocks.
3. GATE Lens & Verified PYQs
Syllabus focus, recurring numerical patterns, common traps, and clearly labelled exam practice. Questions remain source-pending until an official paper and answer key are attached.
Inode maximum file size calculations are a favorite 2-mark numerical question pattern in GATE CS.
- •Given block size and pointer size, calculate the maximum file size or find which pointer level is needed to access byte offset X.
- •Don't forget that block pointer sizes are in BYTES, not bits.
- •To find which pointer is accessed for byte offset B, divide B by Block Size to find the block index, then compare against direct, single, and double ranges.
Exam Practice / Source Verification Required
1 problemConsider a file system with 2 KB block size. An inode contains 10 direct, 1 single indirect, and 1 double indirect pointer. If each block pointer takes 4 bytes, what is the maximum file size (in MB, rounded to nearest integer)?
4. 1-Minute Panic Revision
“Unix Inode: Direct pointers (small files fast) + Indirect pointers (large files supported).”
- •Pointers per index block = Block Size / Pointer Size.
- •Max Blocks = Direct + (P) + (P^2) + (P^3).
- •Max File Size = (Max Blocks) * (Block Size).
- •A file's name is NOT stored in its inode! File names are stored in directory entries mapping name → inode number.
Primary Academic References & Exam Sources
Every concept in Notes From a B.Tech Brain is synthesized from authoritative academic texts, seminal peer-reviewed research, verified exam archives, and renowned university lectures.
Official Chapter 14 slides detailing directory structures, contiguous/linked/indexed allocation, and Unix Inode pointer schemes.
Comprehensive chapter explaining Inode bitmaps, data blocks, indirect pointers, and reading/writing disk paths.
If the textbook derivation did not click immediately, consult these targeted video lessons:
Shortcuts to calculate maximum file size without committing conversion mistakes between block address bits and bytes.
Visual comparison of contiguous allocation external fragmentation vs linked pointer overhead vs indexed multi-level inodes.
Curated lectures on Unix Inode Architecture, File Allocation (Contiguous, Linked, Indexed) & Directory Structures:
The most widely cited video for computing Maximum File Size supported by a Unix Inode.
Textbook-grade visual diagrams comparing random access speeds and storage block chains.
High-accuracy calculation templates for tricky inode capacity questions with power-of-two bytes.
Rigorous operating system storage foundations and sector-level disk layout.