Chapter 9: Persistent Mounts & Storage Operations

22 min read ▅▅ Intermediate Updated July 2026

Learning Objectives

  • Configure persistent mounts in /etc/fstab using UUIDs.
  • Apply production mount options and validate with mount -a.
  • Mount NFS shares temporarily and via fstab.
  • Administer swap and diagnose capacity issues.
  • Repair ext4 and XFS filesystems safely.
  • Troubleshoot deleted-but-open files and monitor disk I/O.

Prerequisites

Complete Chapter 7: Disks, Partitions & LVM first. That chapter covers storage architecture, partitioning, filesystem creation, and LVM basics.

This chapter focuses on production storage operations after disks and volumes are already in place.

Chapter Scope

The sections below cover persistent mounts, NFS client mounts, swap, filesystem repair, and I/O troubleshooting — not introductory partitioning. Return to Chapter 7 if you need fdisk, parted, mkfs, or LVM fundamentals.

Understanding UUID

A filesystem UUID is a stable identifier for a filesystem. Prefer stable identifiers over kernel device names such as /dev/sdb1, which can change after hardware or bus reordering.

Standard Linux filesystem UUIDs use the form 8-4-4-4-12 hexadecimal digits, for example 67bc1234-45ab-4def-8123-456789abcdef.

sudo blkid
sudo lsblk -f
# Example blkid line:
# /dev/sdb1: UUID="67bc1234-45ab-4def-8123-456789abcdef" TYPE="ext4"

Enterprise Insight

Prefer UUID (or another stable identifier such as LABEL or PARTUUID) for ordinary local filesystems in /etc/fstab. LVM paths and network mounts may intentionally use different identity styles — choose the identifier that matches your storage stack.

What is Mounting?

A mount point is the directory where a filesystem is attached — covered in Chapter 7 §7.

Enterprise Insight

Large servers commonly use mount points like /u01, /backup, /data and /oracle.

Temporary Mount & Unmount

sudo mkdir -p /data
sudo mount /dev/sdb1 /data
sudo mount UUID=67bc1234-45ab-4def-8123-456789abcdef /data
sudo umount /data

Important

A filesystem cannot be unmounted while it is in use. Find open files with lsof +f -- /data or fuser -vm /data before forcing anything.

/etc/fstab Configuration Table

The /etc/fstab file defines filesystems that should automatically mount during boot. Copy the UUID from blkid or lsblk -f — do not invent a shortened value.

# Illustrative example only — replace with your real UUID from blkid
UUID=67bc1234-45ab-4def-8123-456789abcdef  /data  ext4  defaults  0  2
FieldDescription
Device / UUIDStable filesystem identifier
Mount PointDirectory where the filesystem is attached
FilesystemType such as ext4 or xfs
OptionsMount options
DumpLegacy dump backup flag (usually 0)
Passfsck order at boot (0 skip, 1 root, 2 others)

Common Mount Options

OptionDescription
defaultsTypical shorthand for rw,suid,dev,exec,auto,nouser,async (confirm on your util-linux version)
rw / roRead-write or read-only
noexecDo not allow executing binaries from this filesystem
nosuidIgnore set-user-ID and set-group-ID bits on this filesystem
nodevDo not interpret device nodes on this filesystem
noatimeSkip atime updates (many systems already use relatime by default)
nofailContinue boot even if this mount fails
_netdevWait for networking (common for NFS/iSCSI)

Enterprise Insight

Validate before reboot:

sudo findmnt --verify --verbose
sudo mount -a
findmnt /data
journalctl -b -u '*.mount' --no-pager | tail

findmnt --verify checks syntax and many dependency issues. mount -a applies fstab and can change system state — run it only after you understand which entries are new.

NFS Client Mounts

NFS lets a Linux host mount a remote directory exported by an NFS server. On the client you need the server hostname (or IP), the export path, and a local mount point.

List exports advertised by a server (when showmount is available):

showmount -e nfs-server.example.com

Mount temporarily for testing:

sudo mkdir -p /mnt/share
sudo mount -t nfs nfs-server.example.com:/export/data /mnt/share
# Some sites prefer NFSv4:
# sudo mount -t nfs4 nfs-server.example.com:/export/data /mnt/share
df -h /mnt/share
sudo umount /mnt/share

Persist the mount in /etc/fstab. For data-bearing shares, prefer hard so the client keeps retrying instead of returning partial I/O errors:

nfs-server.example.com:/export/data  /mnt/share  nfs  defaults,_netdev,hard,timeo=600  0  0
OptionNotes
_netdevWait for networking before mounting at boot
ro / rwRead-only or read-write
hardRetry indefinitely — preferred for most application data shares
softFail after timeouts — can return I/O errors to apps; use only when that failure mode is acceptable

Tip

After editing fstab, run findmnt --verify --verbose, then a controlled mount -a, and confirm with findmnt /mnt/share. Server-side export configuration is out of scope here.

Automount with autofs

When users only need a share occasionally, mounting everything in /etc/fstab can slow boots and leave stale mounts. autofs mounts on first access and unmounts after idle timeout.

The master map is usually /etc/auto.master. A typical indirect map mounts under a base directory (for example /misc) using a map file such as /etc/auto.misc:

# /etc/auto.master
/misc   /etc/auto.misc

# /etc/auto.misc (example — hard preferred for data)
data   -fstype=nfs,hard,timeo=600   nfs-server.example.com:/export/data

After editing maps, restart or reload according to your unit (systemctl restart autofs is the portable choice when reload is unsupported). Access /misc/data to trigger the mount; confirm with findmnt /misc/data. Prefer autofs for home directories and on-demand NFS; keep always-on critical shares in fstab.

Disk Usage Commands

dfdu
Filesystem usageDirectory usage
Total capacityFolder/file size

Repair ext4 & XFS Filesystems

Use this as an operations checklist. Identify the filesystem type first, unmount (or boot to rescue for root), take a backup or snapshot when possible, then run the matching repair tool.

  1. Confirm device and type: lsblk -f / blkid
  2. Unmount the target (or use rescue mode for the root filesystem)
  3. Backup or snapshot when possible
  4. Repair: ext4 → sudo fsck -f /dev/sdb1; XFS → sudo xfs_repair /dev/sdb2 (never run XFS repair through generic fsck)
  5. Remount and verify: mount, findmnt, dmesg / journalctl -b

Warning

Never run fsck on a mounted ext4 filesystem, and never run xfs_repair on a mounted XFS filesystem. Wrong-device repair can destroy data. Disk creation and LVM remain in Chapter 7.

Swap Administration

Swap provides virtual memory when RAM is under pressure. Enabling a plain empty file fails until it has been sized and initialized with mkswap.

# Inspect current swap
swapon --show
free -h

# Create a 2G swapfile (lab or approved maintenance window)
# Prefer dd for a portable, non-sparse file. Wrong of= destroys data — verify the path.
# fallocate can leave sparse/CoW-unsuitable files on some filesystems (e.g. Btrfs).
sudo dd if=/dev/zero of=/swapfile bs=1M count=2048 status=progress
# Alternative on supported filesystems: sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

# Persist in fstab (use the swapfile path or its UUID from blkid)
# /swapfile  none  swap  sw  0  0

sudo swapoff /swapfile   # disable when intentionally removing swap

Deleted but Open Files

A deleted file may still consume disk space if a running process keeps it open.

lsof | grep deleted

Enterprise Insight

Restart the owning process after confirming the deleted file is no longer required.

Storage Performance Monitoring

ToolPurpose
iostatDisk I/O statistics
iotopProcess disk usage
sarHistorical performance

Knowledge Check (MCQs)

  1. Which command repairs an unmounted ext4 filesystem?

    • a) mount -a
    • b) fsck
    • c) df -h
    • d) swapon
  2. Which tool repairs an XFS filesystem?

    • a) fsck
    • b) mkfs.xfs
    • c) xfs_repair
    • d) blkid
  3. Which file stores persistent mount configuration?

    • a) /etc/hosts
    • b) /etc/fstab
    • c) /etc/exports
    • d) /proc/mounts
  4. Which fstab option delays NFS mounts until networking is up?

    • a) noatime
    • b) defaults
    • c) _netdev
    • d) soft
  5. Which command lists NFS exports from a server?

    • a) mount -t nfs
    • b) showmount -e
    • c) findmnt
    • d) df -h
  6. Which command shows filesystem usage?

    • a) du
    • b) lsof
    • c) df -h
    • d) iotop
  7. Which command shows directory size?

    • a) df
    • b) du
    • c) blkid
    • d) umount
  8. Which command helps find deleted files still held open by a process?

    • a) lsof
    • b) fsck
    • c) swapon
    • d) mount
  9. Which command enables swap?

    • a) swapoff
    • b) swapon
    • c) free -h
    • d) iostat
  10. Which tool monitors disk I/O statistics?

    • a) hostname
    • b) iostat
    • c) chsh
    • d) echo
  11. Why prefer UUID in fstab?

    • a) Faster boots than device names
    • b) Stable device identification across renames
    • c) Required for NFS only
    • d) Disables fsck automatically
  12. Should fsck run on a mounted ext4 filesystem?

    • a) Yes, for online repair
    • b) Only with -f
    • c) No — unmount first
    • d) Only on XFS

Commands Covered in This Chapter

  • blkid — show UUID and filesystem type
  • mount / umount — mount or unmount filesystems
  • mount -a / findmnt — apply and inspect fstab mounts
  • showmount — list NFS exports from a server
  • systemctl restart autofs — apply automount map changes (use reload only if the unit supports it)
  • fsck / xfs_repair — check and repair filesystems
  • df / du — report filesystem and directory usage
  • swapon / swapoff — enable or disable swap
  • lsof — list open files (including deleted ones)
  • iostat / iotop / sar — monitor disk I/O