Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Filesystems

A filesystem is the method and data structure an operating system uses to organize, store, retrieve, and manage data on storage devices. It bridges the gap between raw disk blocks and the logical files and directories that users and applications interact with.

Why Filesystems Matter

Without a filesystem, a disk is just a massive array of numbered blocks. A filesystem imposes structure:

  • Naming — files have human-readable names, not just block numbers
  • Hierarchy — directories organize files into a tree
  • Metadata — permissions, timestamps, ownership, size
  • Allocation — which blocks belong to which file
  • Free-space tracking — which blocks are available

Key Concepts at a Glance

ConceptDescription
FileA named collection of bytes with metadata
DirectoryA special file that maps names → inodes/entries
InodeOn-disk structure holding file metadata (not the name)
SuperblockFilesystem-level metadata (size, state, layout)
Block allocationStrategy for assigning disk blocks to files
JournalingWrite-ahead log for crash consistency

Chapter Contents

Interview Quick Facts

  1. Inode vs directory entry: An inode stores metadata + block pointers. A directory entry is just a mapping from filename → inode number.
  2. Hard link vs symlink: Hard link = another directory entry pointing to the same inode (same filesystem only). Symlink = a special file containing a path (can cross filesystems).
  3. VFS lets the kernel support multiple filesystem types through a uniform interface.
  4. Journaling prevents filesystem corruption after a crash by logging intended changes before applying them.

Diagram: Filesystem Layers

graph TD
    A[User Application] --> B[System Call Interface<br>open, read, write, close]
    B --> C[Virtual File System VFS]
    C --> D[ext4]
    C --> E[XFS]
    C --> F[Btrfs]
    C --> G[NTFS]
    C --> H[FUSE]
    D --> I[Block Layer]
    E --> I
    F --> I
    G --> I
    H --> I
    I --> J[Device Drivers]
    J --> K[Disk Hardware]

Cross-References

Cross References