Storage

Configure NFS Client on Rocky Linux 10 / AlmaLinux 10 / RHEL 10

NFS (Network File System) lets Linux systems share directories over a network. An NFS client mounts remote exports from an NFS server and accesses them like local filesystems. This guide covers setting up an NFS client on Rocky Linux 10, AlmaLinux 10, and RHEL 10 – from installing nfs-utils to persistent mounts and autofs.

Original content from computingforgeeks.com - post 19285

We will install the NFS client packages, discover and mount NFS exports manually, configure persistent mounts via /etc/fstab, set up autofs for on-demand mounting, handle SELinux booleans, and troubleshoot common NFS client issues. The steps work on Rocky Linux 10, AlmaLinux 10, and RHEL 10 with nfs-utils 2.8.3 from the default repos. For the server-side setup, see our guide on installing and configuring NFS Server on Rocky Linux.

Prerequisites

  • A server running Rocky Linux 10, AlmaLinux 10, or RHEL 10 with sudo/root access
  • An NFS server with at least one exported share – see the nfs(5) man page for protocol details
  • Network connectivity between client and NFS server (ports 111 and 2049 TCP/UDP)
  • IP address of the NFS server (we use 192.168.1.10 as the example NFS server throughout this guide)

Step 1: Install NFS Client Packages on Rocky Linux 10 / AlmaLinux 10

The nfs-utils package provides the NFS client tools including mount helpers, showmount, and the rpc.statd daemon. Install it with dnf:

sudo dnf install -y nfs-utils

Verify the installed version to confirm the package is in place:

rpm -qi nfs-utils | grep -i version

The output should show nfs-utils version 2.8.3 on Rocky Linux 10 / AlmaLinux 10:

Version     : 2.8.3

Step 2: Discover NFS Exports on the Server

Before mounting, check what shares the NFS server is exporting. Use showmount to query the server:

showmount -e 192.168.1.10

The output lists all available NFS exports and the clients allowed to access them:

Export list for 192.168.1.10:
/srv/nfs/data    192.168.1.0/24
/srv/nfs/backup  192.168.1.0/24

If showmount hangs or returns “clnt_create: RPC: Port mapper failure”, make sure port 111 (rpcbind) and port 2049 (NFS) are open on the server firewall.

Step 3: Create Mount Point and Mount NFS Share Manually

Create a local directory to serve as the mount point:

sudo mkdir -p /mnt/nfs/data

Mount the remote NFS share using the mount command with NFSv4:

sudo mount -t nfs4 192.168.1.10:/srv/nfs/data /mnt/nfs/data

Verify the mount is active with df -h:

df -h /mnt/nfs/data

The output confirms the NFS share is mounted and shows the available space on the remote server:

Filesystem                   Size  Used Avail Use% Mounted on
192.168.1.10:/srv/nfs/data    50G   12G   38G  24% /mnt/nfs/data

You can also confirm the mount type and options with mount:

mount | grep nfs

The output shows the NFS version and mount options in use:

192.168.1.10:/srv/nfs/data on /mnt/nfs/data type nfs4 (rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,local_lock=none,addr=192.168.1.10)

This manual mount will not survive a reboot. The next sections cover persistent mounting.

Step 4: Configure Persistent NFS Mount with /etc/fstab

To mount the NFS share automatically at boot, add an entry to /etc/fstab. Open the file:

sudo vi /etc/fstab

Add the following line at the end of the file:

192.168.1.10:/srv/nfs/data  /mnt/nfs/data  nfs4  defaults,_netdev,rw,hard,intr  0 0

Here is what each option means:

  • nfs4 – use NFSv4 protocol (preferred over NFSv3 for security and performance)
  • defaults – standard mount options (rw, suid, dev, exec, auto, nouser, async)
  • _netdev – tells systemd to wait for network before mounting (critical for NFS)
  • hard – NFS operations retry indefinitely if the server is unreachable (prevents data corruption)
  • intr – allows NFS requests to be interrupted if the server goes down

Test the fstab entry without rebooting:

sudo mount -a

Verify all NFS mounts are active:

df -h -t nfs4

The output should list your NFS mount with filesystem type nfs4:

Filesystem                   Size  Used Avail Use% Mounted on
192.168.1.10:/srv/nfs/data    50G   12G   38G  24% /mnt/nfs/data

Step 5: Set Up Autofs for On-Demand NFS Mounting

Autofs mounts NFS shares on-demand when accessed and unmounts them after a period of inactivity. This is useful when you have many NFS exports but only access them occasionally.

Install autofs:

sudo dnf install -y autofs

Edit the autofs master map to define a mount point base directory:

sudo vi /etc/auto.master.d/nfs.autofs

Add this line to define /nfs as the base directory for auto-mounted NFS shares:

/nfs  /etc/auto.nfs  --timeout=300

The --timeout=300 option unmounts the share after 5 minutes of inactivity. Now create the map file that defines which NFS exports to mount:

sudo vi /etc/auto.nfs

Add entries for each NFS export – the format is key options server:/export:

data   -fstype=nfs4,rw,hard,intr  192.168.1.10:/srv/nfs/data
backup -fstype=nfs4,rw,hard,intr  192.168.1.10:/srv/nfs/backup

Enable and start the autofs service:

sudo systemctl enable --now autofs

Check that the autofs service is running:

systemctl status autofs

The service status should show active (running):

● autofs.service - Automounts filesystems on demand
     Loaded: loaded (/usr/lib/systemd/system/autofs.service; enabled; preset: disabled)
     Active: active (running) since Sat 2026-03-22 10:15:00 UTC; 5s ago

Test by accessing the auto-mount path – autofs will mount the share on first access:

ls /nfs/data

The share mounts automatically and you can see the contents of the remote NFS export. After 5 minutes of inactivity, autofs unmounts it automatically.

Step 6: Configure SELinux Booleans for NFS

Rocky Linux 10, AlmaLinux 10, and RHEL 10 have SELinux enabled in enforcing mode by default. Several SELinux booleans control how NFS shares are accessed. Set the relevant booleans based on your use case.

To allow NFS-mounted home directories (for example, when /home is served over NFS):

sudo setsebool -P use_nfs_home_dirs on

To allow NFS exports with full read/write access:

sudo setsebool -P nfs_export_all_rw on

To allow NFS exports with read-only access:

sudo setsebool -P nfs_export_all_ro on

Verify the boolean values are set correctly:

getsebool -a | grep nfs

The output lists all NFS-related SELinux booleans and their current state:

nfs_export_all_ro --> on
nfs_export_all_rw --> on
use_nfs_home_dirs --> on

The -P flag makes the changes persistent across reboots. Without it, the booleans reset to defaults on the next boot. For more on managing SELinux booleans and contexts, see our dedicated guide.

Step 7: Configure Firewall for NFS Client

The NFS client normally does not need firewall rules opened since it initiates outbound connections. However, if you have a restrictive outbound firewall policy, allow the NFS service:

sudo firewall-cmd --permanent --add-service=nfs
sudo firewall-cmd --permanent --add-service=rpc-bind
sudo firewall-cmd --permanent --add-service=mountd
sudo firewall-cmd --reload

Verify the services are allowed:

sudo firewall-cmd --list-services

The output should include nfs, rpc-bind, and mountd among the allowed services:

cockpit dhcpv6-client nfs rpc-bind mountd ssh

The key ports used by NFS are:

ServicePortProtocol
NFS2049TCP/UDP
rpcbind111TCP/UDP
mountd20048TCP/UDP

Step 8: Verify NFS Mounts

After configuring NFS mounts (manual, fstab, or autofs), verify everything works correctly.

Check mounted NFS filesystems:

df -h -t nfs4

List all NFS mount details including options:

mount -t nfs4

Test read access by listing files on the NFS share:

ls -la /mnt/nfs/data/

Test write access by creating a test file:

touch /mnt/nfs/data/test-file.txt && echo "Write test passed" && rm -f /mnt/nfs/data/test-file.txt

Check NFS statistics to confirm the connection is healthy:

nfsstat -c

This shows client-side NFS RPC statistics. High retransmission counts indicate network issues between client and server.

Troubleshooting Common NFS Client Issues

Permission Denied When Mounting

If you get “mount.nfs4: access denied by server while mounting”, the NFS server is rejecting the client. Check these on the server side:

  • Verify the client IP is in the server’s /etc/exports file
  • Run exportfs -ra on the server to reload exports
  • Check that the exported directory exists and has correct permissions on the server
  • Confirm the firewall on the server allows ports 111 and 2049

Stale File Handle Error

The “Stale file handle” error occurs when the NFS server export was changed or the server was restarted while the client had the share mounted. Fix it by unmounting and remounting:

sudo umount -f /mnt/nfs/data
sudo mount -a

If umount fails because the mount is busy, use lazy unmount:

sudo umount -l /mnt/nfs/data
sudo mount -a

Mount Hangs at Boot

If the system hangs during boot waiting for NFS mounts, the _netdev option may be missing from /etc/fstab. This option tells systemd to wait for network before mounting. Add it to your fstab entry as shown in Step 4.

Another option is to add nofail to the mount options so the system continues booting even if the NFS mount fails:

192.168.1.10:/srv/nfs/data  /mnt/nfs/data  nfs4  defaults,_netdev,rw,hard,intr,nofail  0 0

NFS Version Mismatch

If the server only supports NFSv3 and you are mounting with nfs4, the mount will fail. Force NFSv3 in that case:

sudo mount -t nfs -o vers=3 192.168.1.10:/srv/nfs/data /mnt/nfs/data

Check which NFS versions the server supports:

rpcinfo -p 192.168.1.10 | grep nfs

The output shows the NFS protocol versions available on the server:

    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs

For performance tuning and caching of NFS data locally, consider setting up FS-Cache for NFS on the client. For secure NFS access across networks, see our guide on configuring NFS with Kerberos authentication. NFS shares also work as persistent volume storage for Kubernetes clusters. For more on how the NFS protocol works at the kernel level, see the Linux kernel NFS documentation.

Conclusion

You have configured an NFS client on Rocky Linux 10 / AlmaLinux 10 / RHEL 10 with manual mounts, persistent fstab entries, autofs on-demand mounting, SELinux booleans, and firewall rules. The client can now access remote NFS exports reliably across reboots.

For production use, consider enabling Kerberos authentication for NFS (krb5p) instead of relying on IP-based access control, mounting with the noexec and nosuid options for security, and monitoring NFS performance with nfsstat and mountstats.

Related Articles

AlmaLinux How to Install OpenProject on CentOS 8, Rocky 8, Alma 8 Openstack How To resize or extend Cinder Volume in OpenStack Cheat Sheets Stratis Storage Cheat Sheet – reference guide Cloud Configure NFS Filesystem as OpenNebula Datastores

Leave a Comment

Press ESC to close