How to setup NFS (Network File System) on RHEL/CentOS

We need to install NFS packages on the NFS Server as well as on NFS Client machine. We can install it via “yum” for RHEL/CentOS.

On the NFS server side, run the following commands to setup NFS server.

$ systemctl status nfs
$ mkfs.ext4 /dev/nvme9n1
$ mkdir /mnt/nfsshare

$ vim /etc/exports

$ systemctl restart nfs
$ exportfs -s

On the NFS client side, run the following command to mount the exported NFS share.

$ mkdir /mnt/nfs1
$ mount -t nfs nfs-server-hostname:/mnt/nfsshare /mnt/
$ mount  | grep nfs1
fs-server-hostname:/mnt/nfsshare on /mnt/nfs1 type nfs4 (rw,relatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=,local_lock=none,addr=