Class 22 of 55 • File System & Storage

Linux File System Architecture Guide: Inodes, Types & Formats

 1. What is a Linux File System?

 A File System is the underlying data structure and indexing mechanism by which an operating system controls how data is saved, identified, isolated, and retrieved from physical storage media (such as NVMe SSDs, SATA hard drives, USB flash drives, or network shares). Without a filesystem, data stored on a storage medium would be an unorganized, monolithic stream of billions of raw binary zeroes and ones with no way to tell where one file ends and the next begins.

 Unlike Windows—which assigns individual drive letters (such as C:, D:, and E:) to partitions—Linux treats all storage devices as part of a single, unified, inverted tree structure originating from the single root directory represented by a forward slash (/).

 2. The Golden Unix Principle: "Everything is a File"

 One of the fundamental design philosophies inherited from Unix is that virtually all resources in the operating system are represented as files. This architectural elegance allows software applications to communicate with hard drives, memory, terminal screens, and network sockets using identical, standardized system calls (open(), read(), write(), and close()).

Indicator File Type Description & System Role Example
- Regular / Ordinary File Contains text, source code, multimedia, or binary compiled executables. /etc/hosts, script.sh
d Directory A special file containing a list of filename-to-inode index mappings. /home/student, /var/log
l Symbolic Link A pointer or shortcut containing the pathname to another file or folder. /bin -> usr/bin
b Block Device Hardware storage transferring data in fixed buffered chunks/blocks (e.g., hard drives, flash disks). /dev/sda, /dev/nvme0n1
c Character Device Hardware providing unbuffered, serial stream data byte-by-byte (e.g., terminals, pseudo-random generators). /dev/tty1, /dev/urandom
p Named Pipe (FIFO) First-In-First-Out communication channel allowing two independent processes to exchange data. Created via mkfifo mypipe
s Unix Domain Socket High-performance bi-directional inter-process communication endpoint on the local host. /run/systemd/private

 3. Anatomy of a File System: Superblock, Inodes & Data Blocks

 When a disk partition is formatted with a filesystem (such as ext4), the operating system creates several structural regions across the storage sectors:

Filesystem Region Technical Purpose & Stored Information
Boot Block Occupies the first few sectors of the disk; contains the bootstrap code executed by GRUB or UEFI firmware to load the Linux kernel.
Superblock Stores global metadata describing the entire filesystem: total block count, total inode count, block size (typically 4 KB), volume label, mount counts, and free space allocations. Multiple backup copies are distributed across block groups to enable repair if the primary superblock is corrupted.
Inode Table An indexed array of Inodes (Index Nodes). Every file and directory on the disk has exactly one assigned inode number.
Data Blocks The physical storage sectors where the actual binary payload bytes of files or directory lists are stored.

What Exactly is an Inode?

 An Inode (short for Index Node) is a 256-byte data structure containing all metadata about a file:

  • File type (regular, directory, symlink, device)
  • File size in bytes
  • File permissions (read, write, execute for user/group/others)
  • Owner User ID (UID) and Group ID (GID)
  • Timestamps: atime (last accessed), mtime (last modified), ctime (metadata change time)
  • Link counter (number of hard links referencing this inode)
  • Pointers (direct, indirect, and extents) pointing to the physical data blocks storing the file contents
Crucial Exam Fact: A file's human-readable name is NEVER stored inside the inode itself! Filenames are stored inside the parent directory's data block, which maps names to inode numbers (e.g., "notes.txt" → Inode 142857).

 4. Hard Links vs. Soft (Symbolic) Links

 Linux provides two distinct methods to reference files through multiple paths:

Property Hard Link (ln target link) Soft / Symbolic Link (ln -s target link)
Inode Identity Shares the exact same Inode number as the original file. Possesses its own unique, new Inode number.
Cross-Filesystem Cannot cross partitions (Inodes are only unique within a single filesystem). Can span different partitions, external drives, or network mounts.
Directory Linking Cannot link directories (prevents infinite recursive loops). Fully supports linking directories.
Deletion of Target File data remains completely accessible; data is only wiped when the link count reaches 0. Becomes a dangling (broken) link pointing to a nonexistent destination.

 5. Major Linux File System Types Compared

Filesystem Primary Strengths & Target Environment Max File Size Max Volume Size
ext4 (Fourth Extended) The rock-solid standard for general-purpose computing. Backward compatible, uses extents for continuous block allocation, highly resilient against fragmentation. Default in Ubuntu and Debian. 16 TB 1 EB (Exabyte)
XFS High-performance 64-bit journaling filesystem created by Silicon Graphics (SGI). Optimized for large files, parallel multi-threaded I/O, and enterprise database servers. Default in RHEL, Rocky, and AlmaLinux. 8 EB 8 EB
Btrfs (B-tree FS) Advanced Copy-on-Write (CoW) filesystem featuring integrated subvolumes, writable instant snapshots, online defragmentation, and built-in software RAID. Default in Fedora and openSUSE. 16 EB 16 EB
ZFS (OpenZFS) Enterprise combined storage pool and filesystem with 128-bit capacity, end-to-end data checksumming to eradicate silent data corruption (bit rot), and native drive pooling. 16 EB 256 Quadrillion ZB
VFAT / exFAT / NTFS Cross-platform filesystems used for USB flash drives, SD cards, and dual-boot Windows partitions via the Linux FUSE kernel module (ntfs-3g). 4 GB (FAT32) / 16 EB (exFAT) 2 TB (FAT32) / 128 PB

 6. Practical Lab: Inspecting Inodes and Managing Links

 Let us practice executing essential filesystem inspection and linking commands in the terminal:

Step 1: Inspecting File Inodes with ls -li and stat

# View files along with their unique inode numbers (first column):
ls -li /etc/passwd
# Output: 142857 -rw-r--r-- 1 root root 2842 Nov 02 08:30 /etc/passwd

# View detailed metadata structure using stat:
stat /etc/passwd
# Displays exact Inode, Device ID, Links, Access/Modify/Change timestamps, and block sizes.

Step 2: Creating and Testing Hard vs. Soft Links

# 1. Create a dummy test file:
echo "Mastering Linux File Systems" > original.txt

# 2. Create a Hard Link:
ln original.txt hardlink.txt

# 3. Create a Soft (Symbolic) Link:
ln -s original.txt softlink.txt

# 4. Inspect inodes and link counts:
ls -li original.txt hardlink.txt softlink.txt
# Notice: original.txt and hardlink.txt share the IDENTICAL inode number and have link count = 2!
# softlink.txt has a DIFFERENT inode number and points to original.txt.

# 5. Delete the original file:
rm original.txt

# 6. Test both links:
cat hardlink.txt    # Still displays "Mastering Linux File Systems"!
cat softlink.txt    # Errors out: "No such file or directory" (Broken link)

Step 3: Checking Filesystem Types and Inode Usage

# View mounted filesystems, total storage, and filesystem type:
df -Th

# Check for Inode Exhaustion (crucial troubleshooting command):
df -i
# If an inode column shows 100%, the disk CANNOT create new files even if gigabytes of free disk space remain!

 7. Student Q&A and Viva Preparation

An Inode (Index Node) is a data structure on a Linux filesystem that stores all the metadata about a file—including file type, size, owner UID, group GID, permission bits, timestamps (atime, mtime, ctime), and pointers to disk data blocks. Crucially, the filename itself is NOT stored in the inode; it is stored inside the directory data block alongside the inode number.
A hard link is another directory entry pointing directly to the exact same inode number on the same disk partition; deleting the original filename leaves the data intact as long as at least one hard link exists. A soft link (symlink) is an independent file with its own unique inode containing the string path to another file or directory; symlinks can cross filesystem boundaries and link directories, but become broken (dangling) if the target is deleted or moved.
In Unix and Linux, "Everything is a file" means that almost all system resources—including text files, directories, physical storage devices (/dev/sda), input streams, network communication sockets, and kernel process metrics (/proc)—are exposed to programs through a unified filesystem interface and manipulated using standard system calls like open(), read(), write(), and close().
A journaling filesystem (such as ext4 or XFS) logs intended metadata and data changes to a dedicated circular circular journal area on disk before writing them to the main storage blocks. In the event of a sudden power outage or system crash, the operating system can replay the journal in seconds during reboot, preventing filesystem corruption without requiring hours of manual fsck scanning.
ext4 is the battle-tested, highly backward-compatible default filesystem for Debian/Ubuntu, supporting files up to 16 TB. XFS is a high-performance 64-bit journaling filesystem optimized for massive files and parallel multi-threaded I/O, serving as the default in RHEL/CentOS. Btrfs (B-tree FS) is a next-generation Copy-on-Write (CoW) filesystem featuring integrated snapshots, subvolumes, software RAID, and dynamic expansion, favored by Fedora and openSUSE.

 8. Summary & Next Steps

 You now possess a thorough technical foundation of Linux file structures, inodes, data blocks, and filesystem types. In the next tutorial, we explore the standardized layout of Linux directories in Class 23: The Filesystem Hierarchy Standard (FHS 3.0).

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!