Mount & fstab

mount command, /etc/fstab format, bind mounts, tmpfs, noatime optimization, and autofs lazy mounting.

Overview

Overview Mounting is the act of attaching a filesystem to a directory in the Linux VFS tree. The kernel's mount table tracks every mounted filesystem, its options, and its relationship to other mounts. Understanding mount options and /etc/fstab is essential for building reliable, performant storage configurations.

The mount Command

mount -t is the basic form. Common examples:

/etc/fstab Format

Each line has 6 whitespace-separated fields:

  • Device — UUID=xxx, LABEL=xxx, or /dev/sdX
  • Mount point — absolute path
  • Filesystem type — ext4, xfs, nfs, tmpfs, etc.
  • Mount options — comma-separated (defaults, noatime, ro, ...)
  • dump — 0 (most modern systems) or 1 (back up with dump utility)
  • pass — fsck order at boot: 0 = skip, 1 = root fs first, 2 = other fs

Example:

Key Mount Options

  • noatime — do not update access time on reads. Eliminates a write for every read; significant I/O saving on busy filesystems. Use on all data volumes.
  • ro — mount read-only. Use for rescue operations or read-only bind mounts.
  • noexec — prevent execution of binaries. Use on /tmp and /var/tmp for security hardening.
  • nosuid — ignore setuid/setgid bits. Prevents privilege escalation via setuid binaries on mounted volumes.
  • relatime — update atime only when mtime is newer (a middle ground between atime and noatime).

Key concepts

fstab 6 fields
device, mountpoint, fstype, options, dump, pass. Field 6 (pass) controls fsck order: root=1, others=2, skip=0.
noatime
Suppresses access time updates on reads. Eliminates one write iop per read — measurable improvement on busy filesystems. Safe for almost all workloads; logs still track mtime.
Bind mount
mount --bind /src /dst makes the same filesystem tree visible at two paths. Used heavily by containers and chroots. Does not copy data.
tmpfs
In-memory filesystem backed by RAM and swap. Size-limited via size= option. Perfect for /tmp and build caches. Data is lost on unmount/reboot.
findmnt
Modern replacement for reading /proc/mounts. Shows mount tree with options, source, and propagation. findmnt -t xfs filters by type.
mount -o remount
Change mount options without unmounting. Common recovery pattern: mount -o remount,rw / to make root writable in single-user mode.

When to use it

  • Adding a persistent data volume to a server — write UUID-based fstab entry and test with mount -a
  • Creating a ramdisk for fast temporary storage — tmpfs with size limit prevents OOM
  • Bind-mounting a directory into a chroot or container — mount --bind /host/path /chroot/path
  • Remounting root read-write during recovery — mount -o remount,rw /
  • Explaining why a server boots slow — fstab entry for a missing NFS share causes 90-second timeout

Interview questions

  • Explain the /etc/fstab format and how you would safely add a new entry.
  • What is a bind mount and what are common production use cases?

Sign up free to read the full topic

More Linux topics

Start free on Cariara · Coding problems · System design studio