Linux mount NFS with mount -t nfs server:/path /mnt/local, persistent via /etc/fstab, on-demand via autofs. Production-recommended options: hard,timeo=600,retrans=5,_netdev,noatime. The team that uses these options has reliable NFS. The team that uses defaults has performance issues and boot-time failures.
Table of contents
- The mount command
- Persistent fstab entry
- Production options
- NFS versions
- autofs for on-demand
- User-space NFS (for unprivileged containers)
- Troubleshooting
- FAQ
The mount command
One-off:
sudo mount -t nfs server.example.com:/exported/path /mnt/nfs
The server path uses : separator. The team that gets the path right has it mounted.
Persistent fstab entry
server.example.com:/exported/path /mnt/nfs nfs defaults,_netdev 0 0
_netdev waits for network at boot. mount -a to test. The team that forgets _netdev has boot failures.
Production options
server:/path /mnt/nfs nfs hard,timeo=600,retrans=5,_netdev,noatime 0 0
hard: retry indefinitely on errors.timeo=600: timeout 60s before retry.retrans=5: retries before declaring failure._netdev: network dependency.noatime: don’t update access times (perf).
NFS versions
Specify explicitly:
server:/path /mnt/nfs nfs vers=4.1,_netdev 0 0
- NFSv3: oldest still working.
- NFSv4: Kerberos support.
- NFSv4.1: pNFS.
- NFSv4.2: latest.
Modern servers + clients: v4.1 or v4.2.
autofs for on-demand
# /etc/auto.master
/mnt/nfs /etc/auto.nfs --timeout=60
# /etc/auto.nfs
share -fstype=nfs,rw server:/exported/path
/mnt/nfs/share mounts on access. Unmounts after 60s idle.
User-space NFS (for unprivileged containers)
For containers without root:
unshare -r -m bash
mount -t nfs server:/path /mnt
Or use FUSE-based NFS like nfs-ganesha. The team that runs NFS in user namespaces has rootless access.
Troubleshooting
Common issues:
mount.nfs: Connection timed out: network/firewall.mount.nfs: access denied by server: server’s exports doesn’t include this client.Stale file handle: server restarted. Fix:umount -f /mnt/nfs && mount /mnt/nfs.
The team that uses showmount -e server has visibility into server exports.
FAQ
What’s the difference between NFSv3 and NFSv4?
NFSv4: stateful (single connection for multiple ops), Kerberos support, better locking. NFSv3: stateless, simpler. Most setups use v4 today.
Can I mount NFS as non-root?
Yes with unshare -r -m (user namespace) or FUSE-based NFS. The team that runs NFS in unprivileged contexts has rootless options.
Why is my NFS mount slow?
Default options (add noatime), wrong NFS version, network latency. The team that benchmarks finds the bottleneck.
Can I have multiple clients write to the same NFS share?
Yes - NFS handles concurrent access via locking. Use mount -o lock to ensure proper locking.
What if the NFS server goes down?
With hard mount, client retries indefinitely. With soft, client fails after timeout. The team that uses hard for production has reliable behavior on server outage.
If you are sizing the infrastructure for the kind of project this post covers, the RunxBuild hosting calculator is the right place to model the line items. The compute, the memory, the storage, the bandwidth, the database - each one is a separate number, and the team’s mental model for the platform is the sum of those numbers. The RunxBuild dashboard is where the team sees the actual usage in one place.
Useful related references: