Sub topic 10
Mounting an NFS Export
Prerequisites
This chapter assumes you can use the Linux command line, manage packages with your distribution’s package manager, and read basic file permissions. You also need an NFS server that exports a directory and a client that can reach the server over the network.
NFS, or Network File System, lets a client use a directory from another Linux or Unix-like system as if it were local. The server controls which directories it exports. The client chooses where those directories appear in its own filesystem.
Install the NFS client tools
Install the client package on the machine that will access the export. Package names differ by distribution:
# Debian or Ubuntu
sudo apt update
sudo apt install nfs-common
# RHEL, Rocky, AlmaLinux, or Fedora
sudo dnf install nfs-utilsCreate a local mount point:
sudo mkdir -p /mnt/projectsA mount point is an empty directory where the remote filesystem becomes available. Existing files in that directory are hidden while the export is mounted, so use a dedicated directory.
Discover and mount the export
If the server provides the traditional mount-discovery service, list its exports:
showmount -e fileserverExample output might look like this:
Export list for fileserver:
/srv/nfs/projects 192.168.1.0/24Mount the export using NFS version 4:
sudo mount -t nfs4 fileserver:/srv/nfs/projects /mnt/projectsThe first path identifies the server and exported directory. The second path is the client’s mount point. Check the result:
findmnt /mnt/projects
ls -la /mnt/projects
df -h /mnt/projectsThe findmnt output should show fileserver:/srv/nfs/projects mounted at /mnt/projects.
Understand common mount errors
| Error | Likely cause | Check |
|---|---|---|
| `access denied by server` | Client address is not allowed | `/etc/exports` and the client IP |
| `Connection timed out` | Firewall, routing, or hostname problem | `ping`, DNS, and TCP port 2049 |
| `No such file or directory` | Incorrect export path or mount point | `showmount -e` and `mkdir` |
| `Permission denied` after mounting | UID/GID or mode mismatch | File ownership and numeric IDs |
NFS normally checks numeric user IDs and group IDs. A user named alice on the client does not automatically match a user named alice on the server unless their numeric IDs match or a shared identity service maps them.
Exercise
Which command mounts the server export /srv/nfs/projects from fileserver at /mnt/projects using NFSv4?
Show answer
sudo mount -t nfs4 fileserver:/srv/nfs/projects /mnt/projects