Candid photograph of a Linux server terminal with a soft olive-green glow against a dark slate background, conveying a calm technical atmosphere.

Step-by-step guides for system administrators — covering command-line basics, web server setup, and preparation material for technical interviews.

Browse Tutorials

Setting Up a Simple NFS File Share on CentOS

Network File System remains one of the most practical ways to share directories across Linux servers, and CentOS continues to be a common choice for small businesses and research groups across Australia. Whether you are linking application servers in a Sydney data centre to a storage host in Melbourne, or simply moving build artefacts between a developer workstation in Brisbane and a staging server, NFS provides a lightweight solution that does not require extra user-space daemons or proprietary clients.

This walkthrough assumes two CentOS 7 or 8 hosts with network connectivity and root access. The steps also align with recommendations from the Australian Cyber Security Centre, which encourages explicit export rules and least-privilege access when sharing data between systems subject to the Privacy Act 1988.

Preparing your CentOS environment

Before installing anything, confirm that both the server and the client are running a supported CentOS release. Run cat /etc/centos-release and ensure your packages are current with sudo yum update -y. If you are managing hosts across multiple Australian states, it is worth synchronising time using chrony against an NTP source such as those provided by AARNet, because NFS relies on consistent timestamps for file locking.

Static IP addresses or DHCP reservations are strongly recommended for NFS participants. Hostnames that resolve consistently across sites will save you from debugging intermittent mount failures, particularly when staff connect from interstate branch offices or remote sites such as mining operations in Western Australia.

Installing NFS utilities

The package that provides NFS server and client functionality is nfs-utils. Install it on both machines with sudo yum install nfs-utils -y. On the server, enable and start the required services using sudo systemctl enable --now nfs-server rpcbind, followed by sudo systemctl enable --now rpc-statd. On the client, only rpcbind and the NFS client helpers are needed.

If you are working behind a corporate firewall in Canberra or Adelaide, ensure that ports 2049 (NFS), 20048 (mountd), and 111 (portmapper) are reachable between hosts before proceeding.

Configuring the shared directory

Create the directory you intend to share and set appropriate permissions. A common pattern is to create a dedicated group for users that need access:

sudo mkdir -p /srv/nfs/projects
sudo chown root:nfsusers /srv/nfs/projects
sudo chmod 2770 /srv/nfs/projects

If your organisation processes personal information covered by the Privacy Act, document the data classification of this share and restrict access accordingly. Australian businesses are expected to keep clear records of where sensitive information resides, including on shared storage.

Defining exports and adjusting firewall rules

Edit /etc/exports on the server and add a line for the directory, for example /srv/nfs/projects 10.0.0.0/24(rw,sync,no_subtree_check,no_root_squash). Adjust the subnet to match your environment, then apply the change with sudo exportfs -a. For a deeper look at firewalld zones and rich rules, read our guide on Securing Your CentOS Server with Firewalld Rules.

Remember to reload firewalld after adding services using sudo firewall-cmd --permanent --add-service=nfs, sudo firewall-cmd --permanent --add-service=mountd, sudo firewall-cmd --permanent --add-service=rpc-bind, and finally sudo firewall-cmd --reload.

Mounting the share on a client

On the client, verify visibility first with showmount -e 10.0.0.10, then mount the share temporarily using sudo mount -t nfs 10.0.0.10:/srv/nfs/projects /mnt/projects. For a permanent mount, add an entry to /etc/fstab such as 10.0.0.10:/srv/nfs/projects /mnt/projects nfs defaults,_netdev,x-systemd.automount 0 0.

If the client is geographically distant from the server, for example Perth connecting to a host in Sydney, expect higher latency on the first file access. Tuning the rsize and wsize mount options can help on long-haul links.

Troubleshooting connection issues

When mounts hang or return permission denied errors, check the server's /var/log/messages and run rpcinfo -p from the client to confirm the required RPC services are advertised. SELinux is another frequent culprit on CentOS; enable NFS sharing with sudo setsebool -P nfs_export_all_rw 1.

If NFS feeds content to a web server and you start seeing 502 responses, the underlying issue is often upstream service health rather than NFS itself. Walk through the diagnosis steps in Troubleshooting Common Nginx 502 Bad Gateway Errors to confirm where the failure sits.

Using NFS for shared web and application content

Many Australian agencies and small consultancies use NFS to share static assets, certificate bundles, or media uploads across a pool of web servers. A central export keeps deployments consistent and simplifies backup routines, particularly when web nodes are spread across regions.

This pattern also helps when managing content platforms at scale. For example, when a fleet of WordPress sites draws themes and plugins from a shared mount, a single PHP syntax mistake can take every site down at once. Recovering from a WordPress white screen becomes much easier when the offending file lives on a known NFS path that you can roll back quickly.

Export only what you need, restrict access by subnet or hostname, and keep firewalld rules aligned with your change management process. A simple NFS share is reliable, but its security depends entirely on how carefully you define the export boundaries and keep the underlying services patched.