Migrate to RunxBuild and earn up to $50 in hosting credit on your first deposit.

Calculate your savings
unxBuild

Linux Mount NFS Share: /etc/fstab, mount, and autofs

Sean

Platform Writer

Jul 05, 2026
5 min read

Mounting an NFS share on Linux is mount -t nfs server:/path /mnt/local for a one-off mount, or an /etc/fstab entry for persistent mounts across reboots. For on-demand mounting (only when accessed), use autofs. The team that picks the right approach for the use case has NFS working in seconds; the team that mixes up the options gets silent failures.

Linux Mount NFS Share: /etc/fstab, mount, and autofs

Table of contents

The mount command

One-off mount:

mount -t nfs server.example.com:/exported/path /mnt/local

The -t nfs flag specifies NFS (defaults to NFSv4 if the server supports it). The server exports a path (typically /srv/nfs/shared), the client mounts it locally. The team that gets the path right has the share mounted.

Verify the mount:

df -h | grep nfs
mount | grep nfs

Persistent mounts with /etc/fstab

Edit /etc/fstab:

server.example.com:/exported/path /mnt/local nfs defaults,_netdev 0 0
  • _netdev: Wait for network before mounting (prevents boot-time failures when the network isn’t up yet).
  • defaults: rw, suid, dev, exec, auto, nouser, async.

Then mount -a to test without rebooting, or sudo systemctl daemon-reload and reboot.

The team that forgets _netdev sees boot failures when the NFS server is unreachable. The team that uses _netdev waits for the network and mounts cleanly.

NFS version

Specify the version explicitly when the default doesn’t work:

server.example.com:/exported/path /mnt/local nfs vers=4.1,_netdev 0 0
  • NFSv3: oldest still supported, no Kerberos required.
  • NFSv4: requires server support, native Kerberos.
  • NFSv4.1: parallel NFS (pNFS) for high throughput.
  • NFSv4.2: latest, server-side copy offload.

The team that needs Kerberos security uses NFSv4. The team that needs maximum throughput uses pNFS. The team that has legacy servers uses NFSv3.

Mount options

Common options:

  • rw / ro: Read-write or read-only.
  • sync / async: Synchronous or asynchronous writes.
  • hard / soft: Retry indefinitely or fail after timeout.
  • intr: Allow interrupts on hung NFS (deprecated in NFSv4).
  • timeo=600: Timeout in deciseconds (60s).
  • retrans=5: Number of retransmits before giving up.
  • noatime: Don’t update access times (performance).
  • nosuid, nodev, noexec: Security restrictions.

The team that uses hard,timeo=600,retrans=5 for production has the right balance of reliability and recovery. The team that uses soft sees data corruption on flaky networks.

On-demand mounting with autofs

For shares that should only be mounted when accessed:

# /etc/auto.master
/mnt/nfs /etc/auto.nfs --timeout=60

# /etc/auto.nfs
share -fstype=nfs,rw server:/exported/path

With this, accessing /mnt/nfs/share triggers the mount. After 60s of inactivity, the mount is removed.

The team that uses autofs for rarely-accessed shares (backups, archives) avoids the boot-time dependencies and idle mounts. The team that always-mounts everything in fstab has the network dependencies on every boot.

Troubleshooting

mount.nfs: Connection timed out:

  • Network unreachable to NFS server.
  • Firewall blocking NFS (port 2049 + mountd/rpcbind ports).

mount.nfs: access denied:

  • Server’s /etc/exports doesn’t include this client.
  • Wrong hostname in the export.

Stale file handle:

  • Server restarted and the file handle is no longer valid.
  • Solution: umount /mnt/local && mount /mnt/local.
# Useful debugging commands
rpcinfo -p server.example.com
showmount -e server.example.com
nfsstat -m

FAQ

What’s the difference between NFS and SMB?

NFS is the Unix/Linux standard, works over TCP/UDP, no native encryption (NFSv4 adds Kerberos). SMB is the Windows standard, works over TCP, has native encryption. The team that mixes Linux and Windows uses both: SMB for Windows shares, NFS for Linux.

Is NFS secure?

NFSv3 has no built-in security beyond IP-based access. NFSv4 with Kerberos adds authentication. The team that runs NFS over the public internet uses Kerberos or a VPN. The team that runs NFS on a trusted LAN is fine without.

Why is my NFS mount slow?

Common causes: default options (add noatime,async), wrong NFS version (try v4.1 for pNFS), network latency (measure with nfsstat), or server load. The team that benchmarks NFS throughput finds the bottleneck.

Can I have multiple clients write to the same NFS share?

Yes - NFS handles concurrent access via file locking. The team that has multiple writers uses mount -o lock to ensure proper locking. The team that uses NFS for shared home directories or build artifacts has concurrent access working.

What ports does NFS use?

NFSv4: 2049 (TCP). NFSv3: 2049 + mountd (typically 20048) + rpcbind (111) + nlockmgr. The team that firewalls needs to allow these. The team that uses NFSv4 only needs port 2049.

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:

#nfs#linux#mount#dev-infra