linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Lessons
  • How it works
  • Simulator
  • Knowledge base
  • Interview prep
Index
Categories
All entries
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
home/linux/kb/File system/filesystems

kb/filesystem ── File system ── intermediate

Filesystems: ext4, xfs, btrfs, zfs

ext4 is the reliable default. xfs handles large files and parallel I/O. btrfs and zfs give you snapshots, checksums, and built-in RAID, but they are more complex.

view as markdownaka: zfs, fs-comparison, filesystem-comparison

Why different filesystems exist

A filesystem decides how to lay out blocks on block-devices across inodes, how to find files by name, and what to do about crash recovery, parallelism, and fragmentation. Different priorities lead to different filesystems.

ext4, the workhorse

  • Default on most Linux distributions
  • Journaling (protection against a crash during a write)
  • Up to 1 EiB per filesystem, 16 TiB per file
  • Well studied, stable for 15+ years
  • Downsides: the inode count is fixed at creation; no native snapshots; limited parallelism under heavy load
bash
sudo mkfs.ext4 /dev/sdb1
sudo mkfs.ext4 -L data -m 1 /dev/sdb1   # label "data", reserve 1% (instead of the default 5%)
sudo tune2fs -l /dev/sdb1                # parameters of an existing filesystem
sudo e2fsck -f /dev/sdb1                 # check (only when unmounted!)
sudo resize2fs /dev/sdb1                 # fit to the partition size (after parted)

xfs, for large and parallel loads

  • Default on RHEL/CentOS 7+, a common pick for databases and file servers
  • Scales beautifully across many CPUs and large files
  • Up to 8 EiB
  • Downsides: you cannot shrink the filesystem (grow only); harder to recover after corruption
bash
sudo mkfs.xfs /dev/sdb1
sudo mkfs.xfs -f -L data /dev/sdb1       # -f: force overwrite
sudo xfs_info /mnt/data                   # parameters
sudo xfs_growfs /mnt/data                 # grow (grow only!)

btrfs, copy-on-write

  • Snapshots (like ZFS), subvolumes, native RAID 0/1/10
  • Data and metadata checksums for bit rot detection
  • Downsides: RAID 5/6 has been unstable historically; complex; can fragment under high-write load; recovery is harder than on ext4
bash
sudo mkfs.btrfs -L data /dev/sdb1
sudo btrfs subvolume create /mnt/data/snap-base
sudo btrfs subvolume snapshot /mnt/data/work /mnt/data/snap-2024-01
sudo btrfs balance start /mnt/data        # redistribute blocks

zfs, the most advanced, not in the mainline kernel

  • Checksums, COW, snapshots, send/receive, deduplication, native RAID-Z
  • Bit rot protection at the level of an enterprise SAN
  • Downsides: NOT in the mainline kernel (a CDDL+GPL conflict); installed separately (zfsonlinux); hungry for RAM (the ARC cache); less widespread
  • Main users: TrueNAS, Proxmox, many storage servers

Which one to choose

Use caseRecommendation
Server root, ordinary filesext4
Databases, virtual disks, parallel I/Oxfs
Home NAS with snapshotsbtrfs or zfs
Backup target with deduplicationzfs
Ephemeral container layeroverlay (on top of ext4/xfs)
Embedded / small filesystemsf2fs (NAND-aware)

Tmpfs / overlay / proc / sysfs, the pseudo-filesystems

Not every filesystem lives on disk:

  • tmpfs lives in RAM (/tmp, /run, /dev/shm)
  • proc is /proc, the interface to the kernel and process-and-pid
  • sysfs is /sys, the interface to the device tree and drivers
  • devtmpfs is /dev, dynamic device nodes
  • overlay holds the layers of Docker images (lower + upper = merged view)
  • fuse is a userspace filesystem (sshfs, cephfs, your own)

Journaling

When a write crashes mid-way, the journal helps you recover:

  • ext4 journals metadata (default data=ordered); data=journal covers the data too (slower, safer)
  • xfs keeps the log in a separate zone; you can move it to its own disk (-l logdev=...)
  • btrfs/zfs use COW, so a traditional journal is not needed

Checking integrity

bash
sudo umount /mnt/data           # ALWAYS unmount before fsck
sudo fsck -f /dev/sdb1           # the ext family
sudo xfs_repair /dev/sdb1        # XFS (only in crash mode; a no-op on a healthy filesystem)
sudo btrfs check /dev/sdb1       # btrfs (diagnostics only, does not fix)
sudo btrfs scrub start /mnt/data # btrfs: walk all data, verify checksums

§ команды

bash
sudo mkfs.ext4 -L data /dev/sdb1

Create ext4 with the label data, for use through LABEL=data in fstab

bash
sudo xfs_growfs /mnt/data

Grow XFS to the full partition size (after a parted resize)

bash
sudo tune2fs -l /dev/sdb1 | head

Parameters of an ext filesystem: block size, inode count, mount count, last fsck

bash
sudo btrfs subvolume snapshot /data /data/.snap-$(date +%F)

A btrfs snapshot in one command, instant and copy-on-write

bash
df -hT

All filesystems with their type, a quick view of what is mounted where

§ см. также

  • ext4ext4: the Linux filesystem workhorseext4 is the default filesystem on most distributions: journaling, extents, a fixed inode count set at mkfs time. The main tunes are the data mode, noatime, and lazy init. Stable for 15+ years. Does not scale like XFS.
  • xfsXFS: extents and parallel I/OXFS is the RHEL 7+ default: allocation groups (parallel I/O), extent-based allocation, online grow. **It cannot shrink**, grow only. Ideal for big files, databases, and parallel workloads.
  • btrfsbtrfs: copy-on-write, subvolumes, and snapshotsbtrfs is a copy-on-write filesystem with subvolumes, O(1) snapshots, native RAID 0/1/10, and data checksums. RAID 5/6 is problematic. COW fragmentation hurts databases and VM images, so turn it off for them.
  • mount-and-fstabmount and /etc/fstab: attaching filesystems`mount` attaches a block device or filesystem to a mount point in the tree. `/etc/fstab` is the list of what to mount at boot.
  • fsck-and-recoveryfsck and recovery: checking and repairing a filesystemfsck, a check of an unmounted filesystem. e2fsck (ext), xfs_repair (XFS), btrfs check (btrfs). Journal replay at mount handles 90% of problems after a crash.
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies