Operations 11 min read

Step-by-Step Guide to Setting Up NFS on Rocky Linux 8.9

This tutorial walks through installing NFS utilities, configuring the server and client, setting export permissions, enabling required services and firewall rules, and mounting the shared directory permanently on Rocky Linux 8.9 systems.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Step-by-Step Guide to Setting Up NFS on Rocky Linux 8.9

What Is NFS?

Network File System (NFS) is a distributed file‑system protocol that allows files on a remote server to be accessed and manipulated as if they were on a local disk. Originally released by Sun Microsystems in 1984, NFS works on a client‑server model and supports operations such as read, write, create, delete, and permission management across different operating systems and hardware platforms.

Experimental Topology

Two Rocky Linux 8.9 hosts (named nfs-server and nfs-client) are connected to the same network via the e0 NIC (with NAT on Net1) and to a management network via e1 for remote administration.

Network topology diagram
Network topology diagram

Server Configuration

Install NFS utilities

yum -y install nfs-utils    # Install the NFS utilities package

Verify installation:

rpm -qa | grep nfs    # List installed NFS‑related packages

Create and prepare the shared directory

mkdir /nfsfile                # Create the export directory
chmod 777 /nfsfile           # Grant read/write/execute to everyone
echo 'This is a nfs shared folder.' > /nfsfile/README

Configure export permissions

Edit /etc/exports and add a line that maps the directory to the client subnet. No spaces are allowed between the client address and the option list.

vim /etc/exports
/nfsfile 172.16.0.*(rw,sync,root_squash)

Common export options:

ro : read‑only

rw : read‑write

root_squash : map client‑side root to anonymous UID/GID

no_root_squash : preserve client root privileges

all_squash : map all client users to anonymous

sync : write data to both memory and disk before replying

async : write to memory first for better performance (risk of data loss)

Start and enable required services

systemctl restart rpcbind.service
systemctl enable rpcbind.service
systemctl enable --now nfs-server.service

Open firewall ports

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

Client Configuration

Install NFS utilities and view exports

yum -y install nfs-utils    # Install client utilities
showmount -e 172.16.0.100   # List exports from the server

Output example:

/nfsfile 172.16.0.*

Mount the shared directory

mkdir /nfsfile
mount -t nfs 172.16.0.100:/nfsfile /nfsfile
df -Th   # Verify the mount

Persist the mount via /etc/fstab

# Add the following line to /etc/fstab
172.16.0.100:/nfsfile /nfsfile nfs defaults 0 0

After editing, run mount -a to apply the changes.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxNFSRocky Linuxfile sharing
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.