Operations 19 min read

Mastering NFS: Shared Storage, RPC Architecture, and Deployment Guide

This article explains how NFS provides Linux file sharing, details the RPC-based architecture, walks through server and client configuration, demonstrates integration with nginx, and offers troubleshooting tips for common NFS failures, making it a comprehensive guide for operations engineers.

Raymond Ops
Raymond Ops
Raymond Ops
Mastering NFS: Shared Storage, RPC Architecture, and Deployment Guide

What Is Shared Storage?

Shared storage allows multiple servers to store and access data on a single storage server, enabling consistent data availability across a load‑balanced web cluster.

What Is NFS?

NFS (Network File System) is a Linux‑focused protocol that lets hosts share files or directories over a LAN. It transmits data in clear text and lacks user authentication, so it is typically used only within trusted networks.

NFS Architecture

NFS relies on the RPC (Remote Procedure Call) protocol. Key components include:

rpcbind – registers NFS service ports.

nfs-utils – controls which files are shared and manages permissions.

rpc.nfsd – handles client requests.

rpc.mount – checks client mount permissions.

What Is RPC?

RPC allows a program to request a service from a remote computer without dealing with low‑level network details. It works like calling a local function, but the execution happens on another machine.

Think of RPC as calling a friend to do laundry for you while you stay at home.

Relationship Between NFS and RPC

NFS uses RPC to discover the server’s dynamically assigned ports. The client contacts rpcbind on the server to obtain the correct port, then communicates with the NFS daemon.

NFS Working Principle

1. NFS server starts and registers its ports with rpcbind.
2. NFS client contacts rpcbind (port 111) to get the NFS service port.
3. Client sends file operation requests to the obtained port.
4. Server’s rpc.nfsd validates client permissions.
5. rpc.mount checks mount permissions.
6. Server translates the request into a local kernel operation.

rpcbind Service Role

rpcbind holds the mapping between RPC program numbers and the ports they listen on. Both rpcbind.service and rpcbind.socket must be running for NFS to function.

NFS Server Deployment

The main configuration file is /etc/exports. Its syntax is: /shared/path client1(options) client2(options) Example entries:

/               hostname1(rw) hostname2(rw,no_root_squash)
/pub            *(rw)
/home/chao      123.206.16.61(ro)

Common export options:

ro – read‑only.

rw – read‑write.

root_squash – maps client root to nfsnobody.

no_root_squash – preserves root privileges (use with caution).

all_squash – maps all client users to nfsnobody.

sync – writes data synchronously to disk.

async – buffers writes in memory for performance.

anonuid / anongid – set UID/GID for anonymous users.

Client Address Specification

Clients can be identified by hostname, IP, network range (e.g., 192.168.0.0/24), or wildcard * for all hosts.

rpcbind Management

Ensure rpcbind is active:

# systemctl status rpcbind
# systemctl start rpcbind.service
# systemctl start rpcbind.socket

NFS Server Deployment Steps (Important)

1. Prepare the server machine.
2. Install NFS utilities: yum install nfs-utils rpcbind -y
3. Edit /etc/exports with desired share paths and options.
4. Create the shared directory, e.g., mkdir /nfs-data
5. Start rpcbind: systemctl start rpcbind.service && systemctl start rpcbind.socket
6. Start NFS service: systemctl start nfs
7. Verify exports: showmount -e <server_ip>
8. Adjust permissions (chown -R nfsnobody:nfsnobody /nfs-data) if using squashing.
9. Enable services at boot: systemctl enable rpcbind nfs
10. Reload configuration without reboot: systemctl reload nfs or exportfs -r

NFS Client Deployment (Important)

1. Install client tools: yum install nfs-utils -y
2. Start rpcbind on the client: systemctl start rpcbind
3. Verify rpcbind is listening on port 111.
4. View server exports: showmount -e <server_ip>
5. Create a mount point, e.g., mkdir -p /test-nfs
6. Mount the share: mount -t nfs <server_ip>:/nfs-data /test-nfs
7. Test read/write: ls /test-nfs; touch /test-nfs/hello.log

Integrating NFS with Nginx

To let Nginx serve static files from NFS:

1. Create a dedicated NFS share for Nginx, e.g., /nfs-nginx.
2. Add export with squashing and explicit UID/GID:
   /nfs-nginx 172.16.1.7(rw,sync,all_squash,anonuid=1500,anongid=1500)
3. Reload NFS: systemctl reload nfs
4. Change ownership of the share: chown -R www.www /nfs-nginx
5. Mount on the Nginx host: mount -t nfs 172.16.1.31:/nfs-nginx /usr/share/nginx/html
6. Verify Nginx can read/write files in the mounted directory.

NFS Failure Cases

1. NFS server crash

# systemctl stop nfs   # server stops, client operations hang

Clients may become unresponsive and cannot unmount. Use forced lazy unmount:

# umount -lf /mountpoint

After restarting the server ( systemctl start nfs), the client can access the share again.

2. NFS server crash causing boot hang

If the client mounts NFS via /etc/fstab, a server failure can block boot. Boot into single‑user mode, edit /etc/fstab, or wait for the system to time out and continue.

Key Takeaways

NFS provides simple, LAN‑only file sharing for Linux clusters.

It depends on RPC and rpcbind for dynamic port discovery.

Proper export options (rw, sync, all_squash, anonuid/anongid) are essential for security and permission control.

Both server and client must have rpcbind running; services should be enabled at boot.

Troubleshooting often involves checking rpcbind status, verifying exported lists, and using forced unmounts.

NFS architecture diagram
NFS architecture diagram
NFS workflow diagram
NFS workflow diagram
/etc/exports syntax
/etc/exports syntax
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.

DeploymentRPCLinuxNFSshared-storage
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

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.