Mounting and Filesystem Management with fstab and NFS
You will configure resilient boot-time mounts for local and network filesystems on a server. By the end you will mount a local disk by UUID and an NFS share, both surviving reboot.
Learning Objectives
- Write safe UUID-based fstab entries with the nofail option.
- Mount an NFS share at boot.
- Validate every entry without risking a boot hang.
- Time: ~2 hours · Difficulty: Intermediate · Prereqs: a server plus a local disk and (optionally) an NFS export.
Architecture Overview
graph LR
Disk[(Local disk UUID)] -->|fstab| L[/mnt/local]
NFS[NFS server export] -->|TCP/2049 fstab| N[/mnt/share]
L --> Boot[Persistent at boot]
N --> Boot
Environment Setup
You will need: util-linux, and nfs-common for the NFS portion.
Before you begin: know your disk UUID (blkid) and the NFS server export path.
Step-by-Step Execution
01
Add a local mount by UUID
UUIDs are stable across reboots; nofail avoids a boot hang if the disk is absent.
echo "UUID=$(blkid -s UUID -o value /dev/sdb1) /mnt/local ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab[ROOT REQUIRED] Appends a persistent local mount entry.
02
Add an NFS mount
NFS lets multiple servers share centralized storage over the network.
echo "192.168.1.50:/export/share /mnt/share nfs defaults,_netdev,nofail 0 0" | sudo tee -a /etc/fstab_netdev waits for the network before mounting.
03
Validate without rebooting
# mkdir -p /mnt/local /mnt/share && mount -a && findmnt /mnt/share
TARGET SOURCE FSTYPE OPTIONS
/mnt/share 192.168.1.50:/export/share nfs4 rw,_netdev
Progress So Far
graph LR
A[01 Local mount] -->|done| B[02 NFS mount]
B -->|done| C[03 Validate mount -a]
style A fill:#1a4a1a,stroke:#00ff00,color:#fff
style B fill:#1a4a1a,stroke:#00ff00,color:#fff
style C fill:#1a4a1a,stroke:#00ff00,color:#fff
Testing & Validation
mount -a && df -hT /mnt/local /mnt/shareYou should see both mounts with their filesystem types and no errors from mount -a. If clean, your mounts are boot-safe.
Troubleshooting
- Boot hangs waiting for a mount: add
nofail(and_netdevfor network mounts). - NFS mount times out: confirm the export with
showmount -e 192.168.1.50and firewall on TCP/2049. - Permission denied on NFS: check the export's allowed clients and squash settings.
Extension Ideas
- Replace fstab with a systemd
.mountunit for dependency control. - Combine with LVM for flexible local capacity.
- Secure NFS with Kerberos (sec=krb5p).
Key Results
- Configured local and NFS mounts that persist across reboot.
- Prevented boot hangs with nofail and _netdev options.
- Validated entries safely with
mount -abefore reboot. - Centralized shared storage over NFS for multiple servers.