Skip to main content

Configuring NFS

Installation & Setup


(Guidance based on RHEL/CentOS 77, packages and commands may differ depending on OS)

When

installing

====================================================================================

NFSSHARE SERVER CONFIGURATION

1. Install NFS most chose either NFSv3 or NFSv4, if you have no specific reason to chose one then go with the latter. You can install thispackages on CentOS/RHELNFS withServer

  the following:
  • SERVER: (172.45.55.64)

yum install nfs-utils rpcbind

    2.
  • Start on-boot
  • If this is not a cluster then start these at boot time:

systemctl enable --now rpcbind nfs-server nfs-lock nfs-idmap

    3.
  • Addexports
  • this

    Once installed, we can look to configure the nfs share within the /etc/exports

file:

vim /etc/exports

Add the below config (updated with IP of the client server that need to be able to access the nfsshare. 

/nfsshare 172.45.55.65(IP_IP_IP_IP(rw,sync,no_root_squash)

To specify multiple client servers, add separate lines, as below:

/nfsshare IP_IP_IP_IP(rw,sync,no_root_squash)
/nfsshare IP_IP_IP_IP(rw,sync,no_root_squash)
/nfsshare IP_IP_IP_IP(rw,sync,no_root_squash)

    Once

  • Followedadded, by:
  • you
can publish the exports changes using the below command:

exportfs -a

    =================================================================================

  • CLIENT:

    NFS (172.45.55.65)

  • CLIENT
CONFIGURATION 

1. Install the required NFS packages:

yum install nfs-utils

    2.
  • Testing:
  • Mount

the NFSSHARE (won't persist reboot until next step):

Firstly, create the file path that you wish for the NFSSHARE to be mounted to:

mkdir /nfsshare &&

The below command mounts the NFSSHARE. Ensure to replace the IP_IP_IP_IP:nfsshare with the NFS server IP, and location of the NFSSHARE on the NFS server. Finally, also ensure to update the second /nfsshare on the command to the path you wish for the share to be mounted to on the client server.

mount -t nfs 172.45.55.64:IP_IP_IP_IP:/nfsshare /nfsshare

    3.
  • IfTest the configuration
  • Test that mounting the nfsshare has worked using the df -h command. You should now see an entry dedicated to the NFSSHARE, as below:

     

    4. Permanently configure the NFSSHARE


    Once you've confirmed that the NFSSHARE is working, you can then look to add the fstab entry that will allow this works then you're sorted - add thisconfiguration to persist time & reboots.

    vim /etc/fstab:

Add the below link, ensuring the update the syntax as mentioned above

172.45.55.64:IP_IP_IP_IP:/nfsshare /nfsshare nfs rw,relatime,vers=4,_netdev,timeo=100,retrans=4 0 0
  • Lastly run:
mount -a