Skip to content
linux storage

NFS (NFS)

nfs file-sharing storage network-protocols
Plain English

NFS lets computers share folders over a network. Instead of copying files between machines, you “mount” a folder from a remote server and it appears on your computer as if it were a local drive. Changes are instant because you are working directly on the remote files. It is the standard way Linux servers share storage, from homelab NAS boxes to enterprise file servers.

Technical Definition

Network File System (NFS) is a distributed file system protocol originally developed by Sun Microsystems (1984). It allows a client to access files over a network using the same system calls as local file access, making remote storage transparent to applications.

Versions:

VersionYearKey Features
NFSv31995Stateless, UDP/TCP, widely supported
NFSv42003Stateful, TCP only, ACLs, single port (2049), Kerberos auth
NFSv4.12010pNFS (parallel NFS for distributed storage), sessions
NFSv4.22016Server-side copy, sparse files, application I/O hints

Architecture:

  • Server exports directories via /etc/exports configuration
  • Client mounts exported directories to local mount points
  • NFSv4 uses a single TCP port (2049); NFSv3 requires portmapper (111) plus dynamic ports

Export options:

  • rw / ro: read-write or read-only
  • sync / async: write behavior (sync is safer, async is faster)
  • no_root_squash: allow root on client to act as root on server (security risk; use cautiously)
  • all_squash: map all users to anonymous (most restrictive)

Alternative: SMB/CIFS (Server Message Block): Microsoft’s file sharing protocol. NFS is preferred in Linux/Unix environments; SMB is preferred when Windows clients need access. Samba implements SMB on Linux.

NFS setup and usage

# SERVER: Export a directory
$ sudo apt install nfs-kernel-server

# /etc/exports
/srv/shared    192.168.1.0/24(rw,sync,no_subtree_check)
/srv/backups   192.168.1.0/24(ro,sync,no_subtree_check)

$ sudo exportfs -ra
$ sudo systemctl restart nfs-kernel-server

# CLIENT: Mount the NFS share
$ sudo apt install nfs-common
$ sudo mount -t nfs4 10.0.0.5:/srv/shared /mnt/shared

# Persistent mount via /etc/fstab
$ echo "10.0.0.5:/srv/shared /mnt/shared nfs4 defaults,_netdev 0 0" | \
  sudo tee -a /etc/fstab

# Verify mount
$ df -h /mnt/shared
Filesystem           Size  Used  Avail  Use%  Mounted on
10.0.0.5:/srv/shared 500G  120G  380G   24%   /mnt/shared

# Check NFS server exports
$ showmount -e 10.0.0.5
Export list for 10.0.0.5:
/srv/shared  192.168.1.0/24
/srv/backups 192.168.1.0/24
In the Wild

NFS is the backbone of shared storage in Linux environments. In Proxmox clusters, NFS is commonly used to share ISO images and backup storage across nodes. Kubernetes uses NFS for PersistentVolumes when a full distributed storage solution (Ceph, Longhorn) is overkill. TrueNAS exports ZFS datasets over NFS to serve as centralized storage for VMs and containers. In enterprise environments, NetApp filers and EMC storage arrays serve NFS to thousands of clients. The most common NFS problem is permission mismatches: the client user’s UID/GID must match the server’s expectations, or files appear owned by “nobody.” NFSv4 with Kerberos authentication (sec=krb5p) solves this with cryptographic identity verification and encrypted transport.