NFS (Network File System) lets you share files and folders between Linux systems over a network. In this step-by-step guide, you will learn how to install, configure, and test an NFS server on Oracle Linux 8. Additionally, we will set up an NFS client so it can access the shared folder easily.
Step 1: Install Required Packages for NFS Server
First of all, install the nfs-utils package. This package provides the necessary tools and daemons for running an NFS server.
sudo dnf install nfs-utils
After installation, we can move to starting the NFS service.
Step 2: Start and Enable NFS Service
Next, start the NFS service and enable it so it runs automatically at boot. This ensures your server is ready after a restart.
sudo systemctl enable nfs-server.service
sudo systemctl start nfs-server.service
sudo systemctl status nfs-server.service
Step 3: Create and Export an NFS Share
After starting the service, create the directory that you want to share. In NFS, exports are defined in the /etc/exports file.
First, open the exports file:
sudo nano /etc/exports
Then add an entry like this:
/share/path {client-ip}(rw,sync,no_wdelay,insecure_locks,no_root_squash)
- /share/path → The directory to share.
- {client-ip} → IP address of the client allowed to access it.
- The options rw, sync, and no_root_squash control permissions and behavior.
After that, export the share so the client can access it:
sudo exportfs -arv
Finally, check that the export was successful:
sudo exportfs -s
Step 4: Configure Firewall and SELinux
Before proceeding, you must allow NFS-related services through the firewall. Run these commands:
sudo firewall-cmd --permanent --zone=public --add-service=nfs
sudo firewall-cmd --permanent --zone=public --add-service=rpc-bind
sudo firewall-cmd --permanent --zone=public --add-service=mountd
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
Note: Always use double hyphens (--) before permanent, zone, etc. Otherwise, you may encounter errors.
Moreover, if SELinux is active, you must set the boolean so NFS can export directories:
sudo setsebool -P nfs_export_all_rw 1
Step 5: Configure NFS Client on Oracle Linux 8
On the client machine, first install the required packages:
sudo dnf install nfs-utils nfs4-acl-tools
Then, check available NFS shares on the server by running:
sudo showmount -e {server-ip}
Next, create a directory where you will mount the share:
sudo mkdir -p /mount/path
Finally, mount the shared folder:
sudo mount -t nfs {server-ip}:/share/path /mount/path
Step 6: Make the Mount Persistent
To make sure the mount remains after a reboot, edit the /etc/fstab file:
sudo nano /etc/fstab
Then add this line:
{server-ip}:/share/path /mount/path nfs defaults 0 0
In this way, the mount will automatically reconnect when the system restarts.
Conclusion
By following these steps, you now have a fully functioning NFS server on Oracle Linux 8, and a client configured to access it. This setup allows you to centralize file sharing effectively across your network.