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/mount-and-fstab

kb/filesystem ── File system ── intermediate

mount 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.

view as markdownaka: mount, fstab, mount-options, umount

What "to mount" means

Linux has one directory tree rooted at /. To reach a block-devices, you attach it to the tree: pick a mount point (an empty directory) and tell the kernel "from here on, under this path, you will find the contents of such-and-such device".

bash
sudo mkdir /mnt/data
sudo mount /dev/sdb1 /mnt/data        # ext4 is detected automatically
sudo mount -t xfs /dev/sdb1 /mnt/data  # set the type explicitly

Viewing current mounts

bash
mount                                 # all mounted filesystems (full format)
findmnt                                # the mount tree (more readable)
findmnt /                              # info about one mount point
cat /proc/mounts                       # raw format, always current
df -hT                                 # sizes + filesystem types

Mount options

Pass them with -o, or in the 4th column of fstab. The most important ones:

optionwhat it does
ro / rwread-only / read-write
noexecforbid running binaries from this filesystem (malware defense)
nosuidignore setuid/setgid bits (file-permissions)
nodevignore device nodes
noatimedo not update access time on reads (faster)
relatimeupdate atime only when it is well out of date (default)
sync / asyncsynchronous writes vs caching
defaultsrw,suid,dev,exec,auto,nouser,async
userlet an ordinary user mount it

The trio noexec,nosuid,nodev is standard for /tmp, /home, and user-mounted volumes. It cuts the blast radius of an escalation sharply.

/etc/fstab: what to mount at boot

The format is one line per filesystem, 6 fields separated by whitespace:

# <source>          <target>   <fstype>  <options>            <dump>  <pass>
UUID=abc-123        /          ext4      defaults,errors=remount-ro  0  1
UUID=def-456        /home      ext4      defaults,nodev              0  2
UUID=ghi-789        none       swap      sw                          0  0
tmpfs               /tmp       tmpfs     defaults,nosuid,nodev,size=2G  0  0
/dev/sdb1           /mnt/data  xfs       noatime,nofail              0  2

The fields:

  • source is the UUID/LABEL/device path (UUID is more reliable, names change)
  • target is the mount point
  • fstype is ext4, xfs, tmpfs, nfs, cifs, auto, and so on
  • options are comma-separated with no spaces
  • dump is whether to include it in dump backups (always 0 now)
  • pass is the fsck order at boot: 0 = do not check, 1 = root, 2 = the rest

Apply changes without a reboot:

bash
sudo mount -a                          # mount everything in fstab not yet mounted
sudo systemctl daemon-reload           # systemd generates .mount units from fstab

nofail is required for optional disks: if the disk is missing, it does not block boot.

tmpfs: a filesystem in RAM

bash
sudo mount -t tmpfs -o size=512M tmpfs /mnt/ramdisk

Useful for:

  • /tmp (faster, cleared on reboot)
  • /run, the runtime state of systemd, always tmpfs
  • /dev/shm, POSIX shared memory
  • builds with many temporary files (CI)

Bind mount: the same content in two places

bash
sudo mount --bind /var/data /mnt/duplicate

This is not a copy. It is a second name for the same tree. You see it in:

  • chroot environments (to expose /dev, /proc)
  • jails
  • Docker volumes (-v /host/path:/container/path)
  • read-only views: mount --bind + mount -o remount,bind,ro

Unmounting

bash
sudo umount /mnt/data
sudo umount -l /mnt/data        # lazy: detach from the tree now, release when the last fd closes
sudo umount -f /mnt/data        # force (NFS/userspace only)
# If "device is busy"
sudo lsof +D /mnt/data           # see [[cmd-lsof]]: who holds files there
sudo fuser -vm /mnt/data         # an alternative

NFS / CIFS

bash
# NFS
sudo mount -t nfs server:/export/path /mnt/nfs
# fstab: server:/export/path  /mnt/nfs  nfs  defaults,_netdev  0  0
# CIFS (Samba/Windows)
sudo mount -t cifs //server/share /mnt/win -o username=user,password=pass

The _netdev option means "requires the network, mount after network-online".

§ команды

bash
findmnt

The mount tree in readable form (replaces bare mount)

bash
sudo mount -a

Apply changes in /etc/fstab without a reboot

bash
sudo mount -o remount,rw /

Remount root as rw without unmounting (for recovery)

bash
sudo mount --bind /var/data /mnt/d

Bind mount: the same content at another path (like a Docker volume)

bash
sudo umount -l /mnt/busy

Lazy unmount: detach from the tree now, release later

§ см. также

  • block-devicesBlock devices: disks in LinuxA block device is read and written in fixed-size blocks (usually 512B or 4K). Disks, SSDs, and NVMe drives are all block devices in `/dev/`.
  • cmd-lsblk-blkidlsblk and blkid: block devices and UUIDslsblk shows the block device tree (disk -> partition -> LVM/crypt -> mountpoint). blkid prints UUID, LABEL, and filesystem type. Use them together to write a [[mount-and-fstab|/etc/fstab]] entry by UUID.
  • 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.
  • nfsNFS: Network File SystemNFS is a network file system from Sun. v3 is stateless, v4.1+ is stateful with delegations and pNFS. /etc/exports on the server, mount -t nfs on the client. root_squash, sync/async, and the lock manager are the main options.
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies