Learning Objectives
- Configure persistent mounts in
/etc/fstabusing 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
| Field | Description |
|---|---|
| Device / UUID | Stable filesystem identifier |
| Mount Point | Directory where the filesystem is attached |
| Filesystem | Type such as ext4 or xfs |
| Options | Mount options |
| Dump | Legacy dump backup flag (usually 0) |
| Pass | fsck order at boot (0 skip, 1 root, 2 others) |
Common Mount Options
| Option | Description |
|---|---|
| defaults | Typical shorthand for rw,suid,dev,exec,auto,nouser,async (confirm on your util-linux version) |
| rw / ro | Read-write or read-only |
| noexec | Do not allow executing binaries from this filesystem |
| nosuid | Ignore set-user-ID and set-group-ID bits on this filesystem |
| nodev | Do not interpret device nodes on this filesystem |
| noatime | Skip atime updates (many systems already use relatime by default) |
| nofail | Continue boot even if this mount fails |
| _netdev | Wait 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
| Option | Notes |
|---|---|
| _netdev | Wait for networking before mounting at boot |
| ro / rw | Read-only or read-write |
| hard | Retry indefinitely — preferred for most application data shares |
| soft | Fail 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
| df | du |
|---|---|
| Filesystem usage | Directory usage |
| Total capacity | Folder/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.
- Confirm device and type:
lsblk -f/blkid - Unmount the target (or use rescue mode for the root filesystem)
- Backup or snapshot when possible
- Repair: ext4 →
sudo fsck -f /dev/sdb1; XFS →sudo xfs_repair /dev/sdb2(never run XFS repair through genericfsck) - 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
| Tool | Purpose |
|---|---|
| iostat | Disk I/O statistics |
| iotop | Process disk usage |
| sar | Historical performance |
Knowledge Check (MCQs)
-
Which command repairs an unmounted ext4 filesystem?
- a)
mount -a - b)
fsck - c)
df -h - d)
swapon
- a)
-
Which tool repairs an XFS filesystem?
- a)
fsck - b)
mkfs.xfs - c)
xfs_repair - d)
blkid
- a)
-
Which file stores persistent mount configuration?
- a)
/etc/hosts - b)
/etc/fstab - c)
/etc/exports - d)
/proc/mounts
- a)
-
Which fstab option delays NFS mounts until networking is up?
- a)
noatime - b)
defaults - c)
_netdev - d)
soft
- a)
-
Which command lists NFS exports from a server?
- a)
mount -t nfs - b)
showmount -e - c)
findmnt - d)
df -h
- a)
-
Which command shows filesystem usage?
- a)
du - b)
lsof - c)
df -h - d)
iotop
- a)
-
Which command shows directory size?
- a)
df - b)
du - c)
blkid - d)
umount
- a)
-
Which command helps find deleted files still held open by a process?
- a)
lsof - b)
fsck - c)
swapon - d)
mount
- a)
-
Which command enables swap?
- a)
swapoff - b)
swapon - c)
free -h - d)
iostat
- a)
-
Which tool monitors disk I/O statistics?
- a)
hostname - b)
iostat - c)
chsh - d)
echo
- a)
-
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
-
Should
fsckrun 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 typemount/umount— mount or unmount filesystemsmount -a/findmnt— apply and inspect fstab mountsshowmount— list NFS exports from a serversystemctl restart autofs— apply automount map changes (use reload only if the unit supports it)fsck/xfs_repair— check and repair filesystemsdf/du— report filesystem and directory usageswapon/swapoff— enable or disable swaplsof— list open files (including deleted ones)iostat/iotop/sar— monitor disk I/O