Concept lesson

Linux File Systems & Inodes

ext4 file system layout, inodes, directory entries, hard/soft links, and buffer page cache.

lesson
Freshness: current15 min read
Mastery
not started · 0%

Learning outcomes

  • Understand inode allocations and directory metadata structures
  • Optimize disk I/O with page cache flush settings

Mental model

In Linux, file content is stored in Data Blocks, while file metadata (permissions, ownership, size, pointers to data blocks) is stored in an Inode (Index Node). File names do NOT live in inodes; file names exist in Directory Entries (dentries) mapping names to inode numbers.

Directory Entry (Filename -> Inode #)
Read Inode Metadata (Owner, Mode, Block Pointers)
Kernel Page Cache Lookup
Disk Block Allocation (ext4 Extents)
sync / fsync Flush to Storage
Conceptual teaching model synthesized from:Linux Kernel Kernel.org Official Architecture & Systems Documentation

Theory

  • Inode Structure: Contains metadata for a single file. An inode does not store the filename.
  • Hard Link: A new directory entry pointing to an existing inode number. Increment's the inode link count. Deleting one file name does not delete data until link count reaches 0.
  • Symbolic (Soft) Link: A special file containing a text string path pointing to another filename.
  • ext4 Extents: Replaced block-by-block pointers with contiguous block range allocations (extents), improving large file read/write performance.
# Check inode usage on file system
df -i

# Inspect specific file inode number and metadata
ls -i /etc/passwd
stat /etc/passwd

# Create Hard Link vs Soft Link
ln /var/log/app.log /var/log/app_hard.log
ln -s /var/log/app.log /var/log/app_soft.log

Alternatives and trade-offs

  • ext4: Robust, battle-tested journaling file system; fixed inode count allocated at format time.
  • XFS: High performance, dynamic inode allocation, parallel allocation groups; ideal for large database storage volumes.

Failure modes and misconceptions

  1. "No Space Left on Device" when Disk Space is Available: Creating millions of microscopic files exhausts all allocated Inodes (df -i reads 100%), even when gigabytes of disk space remain free (df -h reads 20%).
  2. Deleting Unlinked Open Files: Deleting a file (rm app.log) while a background process keeps the file handle open removes the dentry, but the kernel retains the inode and data blocks on disk until the process closes the file descriptor.
Reflect before revealing the guide

Decision scenario

Monitor both disk space usage (df -h) and inode consumption (df -i) in production to prevent storage failures caused by inode exhaustion.

Learning outcomes

  • Explain how dentries, inodes, and disk data blocks interact.
  • Distinguish hard links (shared inode pointers) from soft symbolic links.
  • Diagnose storage failures caused by inode exhaustion.

Trade-offs

ext4 journaling ensures filesystem consistency after unexpected crashes, but fixed inode formatting requires monitoring inode exhaustion on dense file workloads.

Evidence assessment

Theory and decision mastery

not-started · 0%
theory0%
decision0%
activityNot mapped
projectNot mapped
1. What is the core architectural principle governing linux filesystem ext4 inodes?
2. What primary operational trade-off must be managed when configuring linux filesystem ext4 inodes?
3. Which failure mode is most commonly observed when linux filesystem ext4 inodes is misconfigured?

Decision scenario

You are designing a high-concurrency production system requiring reliable execution of linux filesystem ext4 inodes under heavy traffic load.

Which architectural decision ensures maximum resilience, scalability, and system stability?

Primary sources