Skip to content

Mounting and fstab

This chapter covers mounting file systems, configuring automatic mounting with /etc/fstab, and systemd mount units for modern Linux systems.


Proper mounting configuration ensures systems boot correctly, data persists, and storage is available. Misconfigured fstab is a common cause of boot failures and downtime.

┌─────────────────────────────────────────────────────────────────────────────┐
│ MOUNTING IN DEVOPS │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ COMMON INCIDENT SCENARIOS │ │
│ │ │ │
│ │ • Boot failure - Wrong fstab entry │ │
│ │ • Mount timeout - Network storage unreachable │ │
│ │ • Read-only filesystem - Options misconfigured │ │
│ │ • Mount order - Dependencies not set │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ PRODUCTION MOUNT OPTIONS │ │
│ │ │ │
│ │ Data Mounts: │ │
│ │ • noatime,nodiratime - Better performance │ │
│ │ • barrier=1 - Data integrity │ │
│ │ • defaults - Standard options │ │
│ │ │ │
│ │ Network Mounts: │ │
│ │ • _netdev - Wait for network │ │
│ │ • x-systemd.automount - On-demand mounting │ │
│ │ • soft,intr - Graceful failure │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘

Terminal window
# Mount basic
sudo mount /dev/sdb1 /mnt/data
# Mount with options
sudo mount -o rw,noexec /dev/sdb1 /mnt/data
# Mount read-only
sudo mount -o ro /dev/sdb1 /mnt/data
# Remount
sudo mount -o remount,rw /
# Unmount
sudo umount /mnt/data
sudo umount /dev/sdb1
# Lazy unmount (force)
sudo umount -l /mnt/data
# Check mounts
mount
findmnt
OptionDescription
rwRead-write
roRead-only
suidAllow setuid
nosuidDisallow setuid
execAllow executables
noexecDisallow executables
autoMount automatically
noautoNo auto mount
userAllow user mount
nouserOnly root can mount
defaultsrw,suid,dev,exec,auto,nouser,async
nofailDon’t fail if device missing

<device> <mount point> <type> <options> <dump> <fsck>
/etc/fstab
# Device Mount Point Type Options Dump Pass
UUID=abc123 / ext4 defaults 1 1
UUID=def456 /boot ext4 defaults 0 2
UUID=ghi789 /home ext4 defaults 0 2
UUID=jkl012 none swap sw 0 0
/dev/sdb1 /mnt/data ext4 defaults 0 2
FieldDescription
DeviceDevice path, UUID, or LABEL
Mount PointTarget directory
TypeFilesystem type (ext4, xfs, nfs, etc.)
OptionsMount options
DumpBackup (0/1)
fsckOrder (0=skip, 1=root, 2=other)

Terminal window
# Find UUID
sudo blkid
ls -l /dev/disk/by-uuid/
# Use in fstab
UUID=abc123-def456-ghi789 / ext4 defaults 0 1
Terminal window
# Label filesystem
sudo e2label /dev/sdb1 mydata
sudo xfs_admin -L mydata /dev/sdb1
# Use in fstab
LABEL=mydata /mnt/data ext4 defaults 0 2

/etc/systemd/system/mnt-data.mount
[Unit]
Description=Data Mount
After=network.target
[Mount]
What=/dev/sdb1
Where=/mnt/data
Type=ext4
Options=defaults
[Install]
WantedBy=multi-user.target
Terminal window
sudo systemctl daemon-reload
sudo systemctl enable mnt-data.mount
sudo systemctl start mnt-data.mount
# Check status
systemctl status mnt-data.mount
/etc/systemd/system/mnt-data.automount
[Unit]
Description=Data Automount
[Automount]
Where=/mnt/data
[Install]
WantedBy=multi-user.target

Terminal window
# Mount NFS
sudo mount -t nfs server:/share /mnt/nfs
# With options
sudo mount -t nfs -o rw,hard,intr server:/share /mnt/nfs
# fstab entry
server:/share /mnt/nfs nfs defaults 0 0
Terminal window
# Mount SMB
sudo mount -t cifs //server/share /mnt/share -o user=username
# With password
sudo mount -t cifs //server/share /mnt/share -o user=username,password=pass
# fstab entry
//server/share /mnt/share cifs credentials=/etc/samba/credentials 0 0
Terminal window
# Mount ISO
sudo mount -o loop,ro image.iso /mnt/iso
# fstab entry
/path/to/image.iso /mnt/iso iso9660 ro,loop 0 0
Terminal window
# Mount tmpfs
sudo mount -t tmpfs -o size=2G tmpfs /mnt/ramdisk
# fstab entry
tmpfs /mnt/ramdisk tmpfs size=2G 0 0

Q: What is the difference between mount and fstab?
A: mount: command to mount immediately; fstab: automatic mount at boot
Q: What does the 'nofail' option do?
A: Don't fail if device doesn't exist (useful for optional mounts)
Q: What is the fsck field in fstab?
A: Order of filesystem check at boot (0=skip, 1=root, 2=other)
Q: How do you find UUID of a device?
A: sudo blkid or ls -l /dev/disk/by-uuid/
Q: What is systemd automount?
A: Mount on first access (on-demand)

WRONG:

/etc/fstab
/dev/sdb1 /data ext4 defaults 0 2
# Device names can change!

CORRECT:

/etc/fstab
UUID=abc123-def456-ghi789 /data ext4 defaults 0 2
# OR
/dev/disk/by-uuid/abc123-def456-ghi789 /data ext4 defaults 0 2

Why: Device names (/dev/sdX) can change between boots, especially in cloud environments.


WRONG:

Terminal window
# Default options - includes atime updates
/dev/sdb1 /data ext4 defaults 0 2
# Every read updates access time - unnecessary I/O

CORRECT:

Terminal window
# With performance options
/dev/sdb1 /data ext4 defaults,noatime,nodiratime 0 2

Why: noatime eliminates unnecessary writes on every file read.


WRONG:

Terminal window
# NFS mount without network wait
server:/share /mnt/nfs nfs defaults 0 0
# Boot hangs if network not ready!

CORRECT:

Terminal window
# Wait for network before mounting
server:/share /mnt/nfs nfs defaults,_netdev,x-systemd.requires=network-online.target 0 0

Why: _netdev ensures the system waits for network before attempting mount.


WRONG:

Terminal window
# Root set to 2 (should be 1)
UUID=... / ext4 defaults 0 2
# Should be: 0 1
# Non-root set to 1 (slows boot)
UUID=... /data ext4 defaults 0 1
# Should be: 0 2

CORRECT:

Terminal window
# Root: 0 1
UUID=... / ext4 defaults 0 1
# Other: 0 2
UUID=... /data ext4 defaults 0 2
# Skip: 0 0
tmpfs /tmp tmpfs defaults 0 0

Why: fsck order determines boot time and what’s checked.


WRONG:

Terminal window
# Missing last two fields
/dev/sdb1 /data ext4 defaults

CORRECT:

Terminal window
# dump: 0=don't backup, 1=backup
# pass: 0=skip fsck, 1=root, 2=check after root
/dev/sdb1 /data ext4 defaults 0 2

Why: Proper pass order ensures correct filesystem checking sequence.


  • mount: Command to mount filesystems
  • fstab: Automatic mount configuration
  • UUID: Preferred way to identify devices
  • systemd: Modern mount units

Chapter 15: Disk Quotas and Limits


Last Updated: February 2026