LFCE 115 🐧 Advanced NFS Mounts
Basic NFS mounting gets a filesystem visible. Advanced mounting is about making that visibility survive reboots, perform under load, behave predictably when the server disappears, and reduce the risk of data corruption. The difference between mount -t nfs server:/export /mnt and a production-grade mount is entirely in the options, the persistence mechanism, and the failure semantics.
This chapter covers the mount options that matter in production: hard versus soft, rsize and wsize tuning, timeo and retrans retry behavior, noatime for write reduction, _netdev for boot ordering, and nconnect for connection parallelism. It also covers autofs as an alternative to static /etc/fstab entries, and the Kerberos security flavors that change what “authenticated” means for an NFS mount.
Key point: The default NFS mount options are not production defaults. They are compatibility defaults. A mount without hard, _netdev, and a deliberate timeo value is a mount that can hang a boot sequence, retry forever without telling anyone, or return I/O errors to applications that cannot handle them.
Why advanced mount options exist
The retry semantics problem. NFS has two failure modes when the server stops responding: hard and soft. A hard mount retries indefinitely until the server returns, which preserves data integrity but can leave a process stuck in uninterruptible sleep. A soft mount returns an I/O error to the application after the timeout expires, which prevents hangs but introduces the possibility of silent data corruption if the application does not handle the error correctly . The choice is not cosmetic; it determines what happens to every process with an open file descriptor when the network fails.
The performance default problem. The default rsize and wsize values are conservative. On modern networks, larger transfer sizes reduce the number of RPC round trips per read or write, improving throughput. AWS recommends rsize=1048576 and wsize=1048576 for EFS , while Azure NetApp Files recommends no larger than 262144 bytes for best overall throughput and latency . The correct value depends on the server, the network, and the workload, which is why it cannot be a single default.
The boot ordering problem. A static /etc/fstab entry for an NFS mount is processed during boot. If the network is not up, or the NFS server is unreachable, the boot can hang waiting for the mount. The _netdev option tells the mount system that this filesystem requires network access, so it waits for the network to be available before attempting the mount . Without _netdev, a down NFS server can prevent a system from reaching a login prompt.
The stale handle problem. Long-lived NFS mounts accumulate state. If the server reboots or the export changes, the client’s file handles become stale. autofs addresses this by mounting on access and unmounting after a period of inactivity, which reduces the window in which stale state can accumulate and frees resources on the client . It is not a replacement for hard mounts, but it changes when and how the mount exists.
a. The hard and soft decision
hard and soft are mutually exclusive recovery behaviors. A hard mount retries NFS requests indefinitely. The process that issued the request blocks until the server responds. This is the correct choice for data integrity: the application never receives a premature error, and the write is not silently lost. The cost is that a process can become unkillable (D state) if the server never returns.
A soft mount gives up after timeo and retrans have elapsed and returns EIO to the application. This prevents hangs but shifts the burden of error handling to the application. Many applications do not handle EIO from a write gracefully; they may crash, retry in a way that duplicates data, or report success incorrectly . AWS explicitly recommends hard and warns that soft mounts carry an inherent risk of data corruption .
# Hard mount: retry forever, safe for data, can hang processes
sudo mount -t nfs -o hard,timeo=600,retrans=2 server:/export /mnt/data
# Soft mount: return EIO after timeout, risks corruption
sudo mount -t nfs -o soft,timeo=150 server:/export /mnt/data
The timeo value is in deciseconds. timeo=600 is 60 seconds. AWS recommends timeo=600 with retrans=2 for EFS . If a soft mount is unavoidable, AWS recommends timeo=150 (15 seconds) at minimum to reduce corruption risk .
b. Tuning rsize, wsize, and nconnect
rsize and wsize control the maximum bytes per READ and WRITE RPC. Larger values mean fewer round trips and higher throughput, up to the point where the network or server becomes the bottleneck. The client and server negotiate the largest supported size if these are not specified, but explicit values can prevent the negotiation from settling on a suboptimal size.
# Explicit 1 MiB transfer sizes for high-throughput LAN
sudo mount -t nfs -o rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 \
server:/export /mnt/data
nconnect is a Linux 5.3+ option that opens multiple TCP connections to the server for a single mount. It increases concurrency without requiring multiple mounts. Microsoft warns that nconnect should not be combined with sec=krb5* options, because the GSS security context is shared across connections and out-of-order packets can trigger frequent context renegotiation . The setting is per-endpoint: all mounts from the same server IP inherit the nconnect value of the first mount .
# Four parallel TCP connections for a single mount
sudo mount -t nfs -o nconnect=4,rsize=262144,wsize=262144,hard \
server:/export /mnt/data
c. Persistence with fstab and autofs
A static /etc/fstab entry is the simplest persistence mechanism. The _netdev option is mandatory for any network filesystem: it tells systemd that the mount depends on network availability, preventing the boot from hanging if the server is unreachable . The nofail option goes further, allowing the boot to complete even if the mount fails entirely.
# /etc/fstab entry for an NFS mount
server:/export /mnt/data nfs rw,hard,timeo=600,retrans=2,_netdev,nofail 0 0
autofs is an alternative that mounts on demand and unmounts after inactivity. It is configured through /etc/auto.master and map files. A direct map specifies the absolute mount point; an indirect map specifies a parent directory and lets the map file define subdirectories .
# /etc/auto.master
/- /etc/auto.direct --timeout=300
# /etc/auto.direct
/mnt/data -fstype=nfs,rw,hard,timeo=600,retrans=2 server:/export
After editing, enable and start autofs:
sudo systemctl enable --now autofs
The --timeout value is the idle time in seconds before the mount is removed. autofs reduces stale mount accumulation and frees resources, but it does not replace hard semantics: a process accessing an autofs mount that the server cannot satisfy will still block under a hard mount.
d. Security flavors and Kerberos
NFSv4 supports Kerberos security flavors that change both authentication and, for krb5p, encryption. The three flavors are krb5 (authentication only), krb5i (authentication plus integrity checking), and krb5p (authentication, integrity, and encryption). The client and server must agree on the flavor, and both must have the necessary Kerberos configuration and kernel crypto support .
# Mount with Kerberos privacy (encryption)
sudo mount -t nfs -o sec=krb5p,hard,timeo=600 server:/export /mnt/data
The flavor is not negotiated automatically. If the server exports with sec=krb5p and the client mounts with sec=sys, the mount will fail. The Gentoo documentation notes that mismatched encryption types between the kernel and krb5.conf produce mysterious failures with no clear error message . Verify that the client and server krb5.conf files list compatible permitted_enctypes before attempting a Kerberos mount.
Complete Example Session
# ============================================
# PART 1: BASIC HARD MOUNT WITH TUNED SIZES
# ============================================
sudo mount -t nfs -o hard,timeo=600,retrans=2,rsize=1048576,wsize=1048576 \
nfs-server:/export/data /mnt/data
# hard: retry forever (data integrity)
# timeo=600: 60-second RPC timeout
# retrans=2: two retries before recovery action
# rsize/wsize: 1 MiB transfer sizes
# ============================================
# PART 2: ADD noatime TO REDUCE WRITES
# ============================================
sudo mount -t nfs -o hard,timeo=600,retrans=2,noatime \
nfs-server:/export/data /mnt/data
# noatime: skip access timestamp updates
# Reduces write load on the server for read-heavy workloads
# ============================================
# PART 3: ADD nconnect FOR PARALLELISM
# ============================================
sudo mount -t nfs -o hard,timeo=600,rsize=262144,wsize=262144,nconnect=4 \
nfs-server:/export/data /mnt/data
# nconnect=4: four TCP connections
# Not compatible with sec=krb5* (GSS context sharing issue)
# ============================================
# PART 4: PERSIST WITH FSTAB
# ============================================
# Add to /etc/fstab:
# nfs-server:/export/data /mnt/data nfs rw,hard,timeo=600,retrans=2,_netdev,nofail 0 0
# _netdev: wait for network before mounting
# nofail: boot completes even if mount fails
sudo mount -a && mount | grep /mnt/data
# ============================================
# PART 5: CONFIGURE AUTofs AS AN ALTERNATIVE
# ============================================
sudo dnf install -y autofs
# /etc/auto.master
# /- /etc/auto.direct --timeout=300
# /etc/auto.direct
# /mnt/data -fstype=nfs,rw,hard,timeo=600 nfs-server:/export/data
sudo systemctl enable --now autofs
# ============================================
# PART 6: VERIFY THE AUTOMOUNT
# ============================================
# Access the mount point to trigger the mount
ls /mnt/data
# Verify it is mounted
mount | grep /mnt/data
# Wait for timeout and verify it unmounts
sleep 310 && mount | grep /mnt/data
# ============================================
# PART 7: KERBEROS MOUNT WITH INTEGRITY
# ============================================
sudo mount -t nfs -o sec=krb5i,hard,timeo=600,retrans=2 \
nfs-server:/export/secure /mnt/secure
# sec=krb5i: authentication + integrity
# Server export must also specify sec=krb5i
# ============================================
# PART 8: KERBEROS MOUNT WITH ENCRYPTION
# ============================================
sudo mount -t nfs -o sec=krb5p,hard,timeo=600 \
nfs-server:/export/confidential /mnt/confidential
# sec=krb5p: authentication + integrity + encryption
# Highest overhead, required for sensitive data in transit
# ============================================
# PART 9: VERIFY MOUNT OPTIONS IN USE
# ============================================
mount | grep nfs-server
# Shows the active options: hard, rsize=..., wsize=..., etc.
# Or inspect /proc/mounts
grep nfs-server /proc/mounts
# ============================================
# PART 10: RECOVER FROM A STALE MOUNT
# ============================================
# If the server changed or the mount is stale:
sudo umount /mnt/data
# If umount hangs due to hard mount:
sudo umount -f /mnt/data
# -f forces unmount (may lose pending writes)
# Or lazy unmount (detach from namespace)
sudo umount -l /mnt/data
The ten parts covered hard mounts with tuned sizes, noatime, nconnect, fstab persistence with _netdev and nofail, autofs configuration, automount verification, Kerberos integrity, Kerberos encryption, option verification, and stale mount recovery.
Quick Reference
Recovery behavior
| Option | Behavior | Risk |
|---|---|---|
hard | Retry indefinitely | Process can hang in D state |
soft | Return EIO after timeout | Application may mishandle error |
intr | Allow signals to interrupt | Deprecated in modern kernels |
Performance options
| Option | Typical value | Effect |
|---|---|---|
rsize | 262144–1048576 | Read transfer size |
wsize | 262144–1048576 | Write transfer size |
nconnect | 4–8 | Parallel TCP connections |
noatime | — | Skip access time updates |
timeo | 600 (60s) | RPC timeout in deciseconds |
retrans | 2 | Retries before recovery action |
Persistence options
| Option | Purpose |
|---|---|
_netdev | Wait for network before mounting |
nofail | Boot completes even if mount fails |
autofs | Mount on access, unmount after idle |
Security flavors
| Flavor | Authentication | Integrity | Encryption |
|---|---|---|---|
sys | UID/GID only | No | No |
krb5 | Kerberos | No | No |
krb5i | Kerberos | Yes | No |
krb5p | Kerberos | Yes | Yes |
Key files
| File | Purpose |
|---|---|
/etc/fstab | Static mount definitions |
/etc/auto.master | autofs master map |
/etc/auto.direct | Direct autofs map |
/etc/krb5.conf | Kerberos configuration |
Best Practices
✅ Do This:
# Use hard mounts for data integrity
mount -o hard,timeo=600,retrans=2 server:/export /mnt/data # ✅
# Add _netdev and nofail to fstab entries
# server:/export /mnt/data nfs rw,hard,_netdev,nofail 0 0 # ✅
# Set explicit rsize and wsize for known workloads
mount -o rsize=262144,wsize=262144,hard server:/export /mnt # ✅
# Use noatime for read-heavy mounts
mount -o noatime,hard server:/export /mnt/data # ✅
# Verify mount options after mounting
mount | grep /mnt/data # ✅
# Use autofs for infrequently accessed shares
# Reduces stale mount accumulation
# /- /etc/auto.direct --timeout=300 # ✅
❌ Don’t Do This:
# Use soft mounts for writable data
mount -o soft server:/export /mnt/data # ❌ (corruption risk)
# Omit _netdev from fstab
# server:/export /mnt/data nfs defaults 0 0 # ❌ (boot hang)
# Combine nconnect with Kerberos
mount -o nconnect=4,sec=krb5p server:/export /mnt # ❌ (context issues)
# Assume defaults are production-ready
mount -t nfs server:/export /mnt/data # ❌ (no hard, no timeout)
# Set rsize/wsize larger than the server supports
mount -o rsize=1048576 server:/export /mnt # ❌ (if server caps lower)
# Use autofs and fstab for the same mount point
# Both will compete for the mount
# (duplicate entry) # ❌
Common Pitfalls
| Pitfall | Why It Happens | Fix |
|---|---|---|
| Boot hangs waiting for NFS | _netdev missing from fstab entry | Add _netdev and nofail |
| Process stuck in D state | hard mount with unreachable server | Expected behavior; restore network or use soft only for non-critical data |
| Poor throughput despite fast network | Default rsize/wsize too small | Set explicit values (262144–1048576) |
| Mount fails with permission denied | Kerberos flavor mismatch | Ensure sec= matches server export and krb5.conf is compatible |
| Autofs mount not triggering | Service not started or map syntax wrong | systemctl enable --now autofs; verify map file |
| Stale file handle | Server rebooted or export changed | Unmount and remount; use autofs to reduce occurrence |
Real-World Examples
1. Hard mount with 1 MiB transfers
mount -o hard,rsize=1048576,wsize=1048576,timeo=600 server:/export /mnt
2. fstab entry with network dependency
server:/export /mnt/data nfs rw,hard,timeo=600,retrans=2,_netdev,nofail 0 0
3. Autofs direct map entry
/mnt/data -fstype=nfs,rw,hard,timeo=600 server:/export
4. Kerberos integrity mount
mount -o sec=krb5i,hard server:/secure /mnt/secure
5. Kerberos encryption mount
mount -o sec=krb5p,hard server:/confidential /mnt/conf
6. nconnect for throughput
mount -o nconnect=4,rsize=262144,wsize=262144,hard server:/export /mnt
7. Read-only mount with noatime
mount -o ro,noatime,hard server:/archive /mnt/archive
8. Soft mount for non-critical scratch
mount -o soft,timeo=150 server:/scratch /mnt/scratch
9. Verify active options
grep /mnt/data /proc/mounts
10. Force unmount a hung mount
umount -f /mnt/data || umount -l /mnt/data
Visual
The hard vs soft decision
┌─────────────────────────────────────────────────────────────┐
│ SERVER STOPS RESPONDING │
│ │
│ hard mount: │
│ Process ──► RPC request ──► no response │
│ │ │ │
│ ▼ ▼ │
│ Sleep (D state) ◄──── retry forever │
│ Data integrity preserved │
│ Process may be unkillable │
│ │
│ soft mount: │
│ Process ──► RPC request ──► timeout (timeo × retrans) │
│ │ │ │
│ ▼ ▼ │
│ EIO returned ◄──── give up │
│ Application must handle error │
│ Risk of silent corruption │
└─────────────────────────────────────────────────────────────┘
fstab ordering with _netdev
┌─────────────────────────────────────────────────────────────┐
│ BOOT SEQUENCE WITH _netdev │
│ │
│ Without _netdev: │
│ Boot ──► fstab processed ──► NFS mount attempted │
│ │ │
│ ▼ │
│ Network not ready │
│ │ │
│ ▼ │
│ BOOT HANGS │
│ │
│ With _netdev: │
│ Boot ──► network.target reached ──► fstab NFS mount │
│ │ │
│ ▼ │
│ Mount succeeds or nofail skips │
└─────────────────────────────────────────────────────────────┘
Autofs lifecycle
┌─────────────────────────────────────────────────────────────┐
│ AUTOfs MOUNT LIFECYCLE │
│ │
│ Process accesses /mnt/data │
│ │ │
│ ▼ │
│ autofs sees access, mounts NFS share │
│ │ │
│ ▼ │
│ Mount active, I/O proceeds normally │
│ │ │
│ ▼ │
│ No access for --timeout seconds │
│ │ │
│ ▼ │
│ autofs unmounts the share │
│ │ │
│ ▼ │
│ Resources freed, stale state reduced │
└─────────────────────────────────────────────────────────────┘
Security flavor comparison
┌─────────────────────────────────────────────────────────────┐
│ NFS SECURITY FLAVORS │
│ │
│ sec=sys │
│ UID/GID only, cleartext, no encryption │
│ Suitable for trusted internal networks │
│ │
│ sec=krb5 │
│ Kerberos authentication, no integrity, no encryption │
│ Proves identity, not data protection │
│ │
│ sec=krb5i │
│ Kerberos + integrity checking │
│ Detects tampering, does not encrypt │
│ │
│ sec=krb5p │
│ Kerberos + integrity + encryption │
│ Highest overhead, required for sensitive data │
└─────────────────────────────────────────────────────────────┘
Summary
| Item | Value |
|---|---|
| Recovery default | hard for data integrity |
| Timeout unit | Deciseconds (timeo=600 = 60 seconds) |
| Retry count | retrans=2 (AWS recommendation) |
| Transfer sizes | 262144–1048576 bytes depending on server |
| Parallel connections | nconnect (Linux 5.3+), not with Kerberos |
| fstab requirement | _netdev for network filesystems |
| Boot safety | nofail prevents boot failure on mount error |
| On-demand alternative | autofs with --timeout |
| Encryption option | sec=krb5p (requires Kerberos) |
Key takeaways:
hardis the production default for writable data.softprevents hangs but shifts error handling to applications that often cannot handle it, risking corruption.timeoandretranscontrol how long a hard mount waits before signaling a problem.timeo=600, retrans=2is a reasonable starting point for LAN mounts._netdevis mandatory for fstab entries. Without it, a down NFS server can prevent the system from booting to a usable state.rsizeandwsizeshould be explicit, not negotiated. The correct value depends on the server, but modern defaults are often too conservative.nconnectincreases concurrency but conflicts with Kerberos. Do not combinenconnectwithsec=krb5*options.autofsreduces stale state but does not change failure semantics. A hard mount accessed through autofs still blocks when the server is unreachable.- Kerberos flavors are all-or-nothing. The client’s
sec=value must match the server’s export, and both sides need compatiblekrb5.confencryption types.
Remember: Advanced NFS mounting is about making deliberate choices instead of accepting defaults. The three choices that matter most are hard versus soft (data integrity versus hang avoidance), _netdev versus bare fstab (boot safety), and explicit rsize/wsize versus negotiation (throughput control). Every other option adjusts performance or security around those three decisions. A mount that omits hard and _netdev is not “simpler”; it is a mount that has not decided what to do when the network fails.
Stop using slow, ad-bloated tool sites! 🤮
🔎 Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)
⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free
🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!