Skip to main content
RunBook Academy

LinuxLIX · Shared Storage and ClustersNFS

NFS as cluster storage - the simple shared filesystem

Intermediate⏱ ~10 minnfs-kernel-servernfs-common

What you'll learn

  • Use NFS for shared cluster storage
  • Configure an NFS server and client
  • Recognise the production considerations
  • Choose NFS over alternatives

Prerequisites

Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09

Not yet marked complete on this device.

NFS (Network File System) is the standard shared filesystem for Linux clusters. It is simple, well-supported, and works across distributions. This lesson covers how to use it.

What NFS does

NFS allows multiple hosts to mount the same filesystem over the network:

NFS server (10.0.0.50)
  └── /srv/shared  (exported)

NFS client 1 (10.0.0.10)
  └── mount 10.0.0.50:/srv/shared /mnt/shared

NFS client 2 (10.0.0.11)
  └── mount 10.0.0.50:/srv/shared /mnt/shared

Both clients see the same files. The server is the source of truth.

NFS versions

  • NFSv3: widely supported, no encryption, no Kerberos.
  • NFSv4: modern, supports Kerberos, encryption, locking.
  • NFSv4.1: pNFS (parallel NFS) for high throughput.
  • NFSv4.2: latest.

For new deployments, use NFSv4.2.

Configure NFS server

# Install
sudo apt install nfs-kernel-server

# Create the export directory
sudo mkdir -p /srv/shared
sudo chown nobody:nogroup /srv/shared

Then declare the export. This is a configuration file, not a command — pasting the line below into a shell is a syntax error, because ( and ) are shell metacharacters:

# /etc/exports
/srv/shared 10.0.0.0/24(rw,sync,no_subtree_check)

Apply and confirm it:

sudo exportfs -ra          # re-read /etc/exports
sudo exportfs -v           # what is actually exported, with resolved options

exportfs -ra reports syntax errors on stderr and keeps the previous table, so read its output rather than assuming a silent run means success.

/etc/exports options:

  • rw / ro: read-write or read-only.
  • sync / async: synchronous or asynchronous writes.
  • no_subtree_check: disable subtree checking (faster, but less safe).
  • no_root_squash: do not map root to nobody (security risk; use carefully).
  • sec=sys / sec=krb5: security flavor (sys for default, krb5 for Kerberos).

Apply:

sudo exportfs -a

Configure NFS client

# Install
sudo apt install nfs-common

# Mount
sudo mount 10.0.0.50:/srv/shared /mnt/shared

Or in /etc/fstab:

10.0.0.50:/srv/shared /mnt/shared nfs defaults,_netdev 0 0

_netdev waits for the network to be up before mounting.

NFS performance

NFS performance depends on:

  • Network latency.
  • Server disk speed.
  • NFS version (v4 is faster than v3).
  • Sync vs async writes.
  • Block size (rsize and wsize mount options).

For high throughput:

10.0.0.50:/srv/shared /mnt/shared nfs rsize=1048576,wsize=1048576,hard 0 0

Production considerations

  • Single point of failure: the NFS server is. Use a clustered filesystem (GlusterFS, CephFS) for HA.
  • Network dependency: NFS over a slow network is slow.
  • Locking: NFSv4 has better locking than NFSv3 but is not as good as local filesystems.
  • Security: NFSv3 has no authentication. Use NFSv4 with Kerberos for security.

For cluster applications, prefer stateless where possible. NFS is good for static assets and small files.

Knowledge check

Knowledge check · 3 questions

  1. Q1. Which NFS version should new deployments use?

  2. Q2. NFSv3 is secure for production.

  3. Q3. Which of the following are valid NFS options? Select all that apply.

Passing score: 75%. Answers are checked in this browser.