devutils/ATFQ/book ATFQ git

Part I · How it works

9. How filesystems work

  1. 9.1How a filesystem stores a fileA disk is a long row of blocks (usually 4 KiB). A filesystem decides which blocks hold which file, and keeps that map on the disk too.
  2. 9.2Journaling: how a filesystem survives a crashCreating a file touches several places on disk: the inode, the folder, the free-space map. A crash in between would leave them disagreeing.
  3. 9.3Copy-on-write filesystems: snapshots and checksumsBtrfs and ZFS never overwrite data in place: changes go to new blocks, then one pointer switches. The filesystem is always consistent.
  4. 9.4ext4, XFS, btrfs or ZFS?ext4: the safe default (Debian, Ubuntu). Mature, fast, repairable.
  5. 9.5The VFS: one interface for every filesystemPrograms call open, read and write the same way whatever holds the file. The kernel's VFS turns those calls into the right filesystem's code.