Install NFS server on RHEL 8.x

By | March 2, 2021

Network File System (NFS) also known as client/server file system is a popular, cross-platform and distributed file system protocol used to export local file systems over the network so that clients can share directories and files with others over a network and interact with them as though they are mounted locally.

Credit: tecmint.com

1. Demonstration LAB info

  • OS: Red Hat Enterprise Linux 8.x x86_64
  • Hostname: RH8NFS
  • IP: 192.168.100.30
  • CPU: 2 Cores
  • RAM: 2 GB
  • Disk: 30 GB

2. Configure local repository to install packages from RHEL disk

3. Install NFS server package requirement

dnf install nfs-utils

4. Start and enable NFS server service

systemctl enable nfs-server --now

5. Configure local firewall settings

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

6. Create NFS sharing directory named “/share/nfsdata” and permission

mkdir /share/nfsdata
chmod -R 755 /share/nfsdata

7. Configure NFS sharing directory “/share/nfsdata” in exports “/etc/exports”

echo "/share/nfsdata  192.168.100.0/24(rw,sync,no_root_squash,no_all_squash)" >> /etc/exports

8. To export above file system, run “exportfs” command

exportfs -arv

9. To display the current export list, run the below command

exportfs -s

10. For NFS client that will need to connect NFS server sharing directory

  • Install NFS client packages requirement
dns install nfs-utils
  • Then run the showmount command to show mount information for the NFS server
showmount -e 192.168.100.30
  • Create mount directory for NFS client
mkdir /nfsdata
  • Configure “/etc/fstab” to mount sharing directory from NFS server
echo "192.168.100.30:/share/nfsdata   /docker-data    nfs     defaults        0 0" >> /etc/fstab
  • Start to mount NFS sharing with command
mount -a
df -h

Leave a Reply

Your email address will not be published. Required fields are marked *