Sub topic 8
NFS Versions and How They Work
This chapter assumes you can use the Linux command line, manage services with systemctl, and understand IP addresses, users, groups, and file permissions. You will learn how Network File System (NFS) versions differ and how an NFS client accesses files on a server.
The NFS working model
NFS lets a client use a directory on a remote Linux or Unix-like server as if it were part of its local filesystem. The server exports a directory. The client mounts that export at a local mount point.
The client does not copy the whole directory. Instead, filesystem operations become network requests. For example, reading a file causes the client to send an NFS read request to the server. The server performs the read and returns the data.
An NFS export is a server-side directory made available to selected clients. The server controls which clients can connect in /etc/exports. The client chooses where to attach the export with the mount command.
Comparing NFS versions
| Version | Main characteristics | Network considerations |
|---|---|---|
| NFSv3 | Stateless operations, widely supported, separate locking and mount services | May require several RPC services and ports |
| NFSv4 | Integrated locking, ACL support, stronger protocol design, a server namespace | Usually uses TCP port 2049 |
| NFSv4.1 and later | Sessions, better recovery, and optional parallel NFS features | Uses the NFSv4 model and normally port 2049 |
NFSv3 is called stateless because the server does not need to maintain open-file state between each request. Requests contain enough information for the server to process them. Locking and mounting commonly use separate services, such as rpcbind, mountd, statd, and lockd.
NFSv4 is stateful. It tracks operations such as opens, locks, and client sessions. This supports better locking and recovery behavior. NFSv4 also combines several older services into the main protocol and normally uses TCP port 2049. It presents exports through a server namespace, sometimes called a pseudo-filesystem.
Choose NFSv4 for new Linux deployments unless an older client requires NFSv3. NFSv3 can be useful when compatibility is more important than simpler firewalling.
Mounting an NFSv4 export
After the server exports /srv/nfs/projects, a Linux client can mount it as follows:
sudo mkdir -p /mnt/projects
sudo mount -t nfs4 fileserver:/srv/nfs/projects /mnt/projects
findmnt /mnt/projectsThe nfs4 type selects NFSv4. findmnt confirms that the mount is active and shows the negotiated filesystem type and options. The path after the server name must match the namespace presented by the server. A server may expose an export under a different visible path than its physical directory.
NFSv4 can also use Kerberos for authentication and message protection. Kerberos requires correct hostnames, synchronized clocks, and a configured security realm. Without it, access control depends mainly on client addresses, Unix IDs, export options, and filesystem permissions.
Exercise
Why is NFSv4 often easier to protect with a firewall than NFSv3?
Show answer
NFSv4 normally carries its main protocol traffic over TCP port 2049, while NFSv3 commonly needs additional RPC services and ports.