OPERATING SYSTEMS/Student Engineering Notebook
Page 14·notes
FILE SYSTEMS & STORAGE ARCHITECTURE—~22 MIN READ·GATE CS LENS

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

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.

WORKED NUMERICAL · STUDENT DERIVATION✎ Key Takeaway: In GATE, remember that Pointers Per Block = (Block Size) / (Pointer Size). Triple indirect dominates the capacity: (PointersPerBlock)³ × BlockSize.

2. Worked Calculation: Maximum File Size

Problem Statement:
An Inode contains 12 direct pointers, 1 single indirect, 1 double indirect, and 1 triple indirect pointer. Disk block size is 4 KB (4096 bytes), and a disk block address pointer is 4 bytes. Calculate the maximum file size supported by this file system.
Block Size4 KB = 4096 bytesBlock Pointer Size4 bytesPointers per Block4096 / 4 = 1024 = 2^10 pointers
Step 1: Direct Blocks Capacity

12 direct pointers point to 12 data blocks.

12 * 4 KB = 48 KB
Step 2: Single Indirect Capacity

One pointer points to a block containing 1024 pointers.

1024 * 4 KB = 2^10 * 2^12 B = 2^22 B = 4 MB
Step 3: Double Indirect Capacity

1024 * 1024 = 2^20 pointers to data blocks.

1024 * 1024 * 4 KB = 2^20 * 2^12 B = 2^32 B = 4 GB
Step 4: Triple Indirect Capacity

1024 1024 1024 = 2^30 pointers to data blocks.

1024^3 * 4 KB = 2^30 * 2^12 B = 2^42 B = 4 TB
Final Answer:Max File Size = 48 KB + 4 MB + 4 GB + 4 TB ≈ 4.004 TB
GATE LENS · EXAM PREPARATION

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.

EXAM WEIGHTAGE & FOCUS:

Inode maximum file size calculations are a favorite 2-mark numerical question pattern in GATE CS.

recurring exam patterns:
  • •Given block size and pointer size, calculate the maximum file size or find which pointer level is needed to access byte offset X.
⚠ common student traps:
  • •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 problem
GATE-style question · 2 MarksPointers per block = Block Size / Pointer Size. Max Size = Direct + Single*B + Double*B^2.

Consider 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)?

A. 256 MB
B. 513 MB
C. 1024 MB
D. 2048 MB
RAPID REVIEW · NOTEBOOK SUMMARY

4. 1-Minute Panic Revision

core principle:

“Unix Inode: Direct pointers (small files fast) + Indirect pointers (large files supported).”

must-remember principles:
  • •Pointers per index block = Block Size / Pointer Size.
  • •Max Blocks = Direct + (P) + (P^2) + (P^3).
  • •Max File Size = (Max Blocks) * (Block Size).
critical exam pitfalls:
  • •A file's name is NOT stored in its inode! File names are stored in directory entries mapping name → inode number.
decision flow & invariants:
[ UNIX INODE POINTER HIERARCHY & MAXIMUM CAPACITY ] INODE STRUCTURE (Fixed-size metadata header): ┌─────────────────────────────────────────────────────────────┐ │ [ Direct Pointers 0–11 ] ───> Data Blocks │ (12 × BlockSize) ├─────────────────────────────────────────────────────────────┤ │ [ Single Indirect ] ───> Index Block │ │ │ │ │ ▼ │ │ Data Blocks │ (P × BlockSize) ├─────────────────────────────────────────────────────────────┤ │ [ Double Indirect ] ───> Index Block │ │ │ │ │ ▼ │ │ Index Blocks │ │ │ │ │ ▼ │ │ Data Blocks │ (P² × BlockSize) ├─────────────────────────────────────────────────────────────┤ │ [ Triple Indirect ] ───> Index → Index → Data Blocks │ (P³ × BlockSize) └─────────────────────────────────────────────────────────────┘ * P = (Block Size in Bytes) / (Pointer Size in Bytes)
SOURCE TRANSPARENCY & CITATIONS

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.

Primary Academic Texts
Operating System Concepts (10th Edition)↗by Silberschatz, Galvin, Gagne · Chapter 14: File-System Implementation (Section 14.4: Allocation Methods & Unix Inode)

Official Chapter 14 slides detailing directory structures, contiguous/linked/indexed allocation, and Unix Inode pointer schemes.

ACADEMIC STANDARD
Operating Systems: Three Easy Pieces (OSTEP)↗by Remzi H. Arpaci-Dusseau & Andrea C. Arpaci-Dusseau · Chapter 40: File System Implementation (The Inode & Multi-Level Indexing)

Comprehensive chapter explaining Inode bitmaps, data blocks, indirect pointers, and reading/writing disk paths.

ACADEMIC STANDARD
ALTERNATIVE PEDAGOGICAL PERSPECTIVES

If the textbook derivation did not click immediately, consult these targeted video lessons:

Unix Inode Structure with Numerical Example | OSGate Smashers (Varun Singla) (14 mins)

Shortcuts to calculate maximum file size without committing conversion mistakes between block address bits and bytes.

Watch Lesson↗
File Allocation Methods (Contiguous, Linked, Indexed)Gate Smashers (Varun Singla) (15 mins)

Visual comparison of contiguous allocation external fragmentation vs linked pointer overhead vs indexed multi-level inodes.

Watch Lesson↗
RECOMMENDED YOUTUBE LECTURES & EDUCATORS: MODULE 8: FILE SYSTEMS & STORAGE ARCHITECTURE

Curated lectures on Unix Inode Architecture, File Allocation (Contiguous, Linked, Indexed) & Directory Structures:

Gate Smashers · L-7.7: Unix Inode Structure with Numerical Example↗Instructor: Varun Singla · Covers: Direct block pointers (12), Single Indirect, Double Indirect, Triple Indirect block calculations

The most widely cited video for computing Maximum File Size supported by a Unix Inode.

Open YouTube↗
Neso Academy · The UNIX Inode & File Allocation Methods↗Instructor: Neso Academy · Covers: Contiguous vs Linked Allocation (FAT table) vs Indexed Allocation, Internal vs External fragmentation

Textbook-grade visual diagrams comparing random access speeds and storage block chains.

Open YouTube↗
Knowledge Gate · Inode Numerical Questions for GATE & Semesters↗Instructor: Sanchit Jain · Covers: Disk block size variations, Disk block address sizes, GATE PYQs on inode pointer limits

High-accuracy calculation templates for tricky inode capacity questions with power-of-two bytes.

Open YouTube↗
Ravindrababu Ravula · File System Organization & Inodes↗Instructor: Ravindrababu Ravula · Covers: Superblock, Inode table in disk partition, Free space management (Bit vector, Grouping, Counting)

Rigorous operating system storage foundations and sector-level disk layout.

Open YouTube↗