Tuesday, 1 September 2020

How to Install and Configure NFS Server on CentOS 8




NFS (Network File System) is a distributed network file sharing system protocol. It is provides to share files and folders between Linux distributions over the network. It can locally mounted the NFS files systems from the NFS server to the client machines and accessible the files and directories like local file system.

This article describes How to install and Configure NFS Server on CentOS8.

NFS Server Configuration:

Step 1. Package installation: NFS Server package is available in CentOS8 BaseOS repository. Run the following command to install NFS Server packages:

[root@linuxcnf ~]# dnf install nfs-utils
CentOS-8 - AppStream
………………..
Installed:
  nfs-utils-1:2.3.3-31.el8.x86_64

Complete!
[root@linuxcnf ~]#

Step 2. Start Services: Once the packages are installed start the services and enable to start on boot up:

[root@linuxcnf ~]# systemctl enable --now nfs-server
Created symlink /etc/systemd/system/multi-user.target.wants/nfs-server.service /usr/lib/systemd/system/nfs-server.service.
[root@linuxcnf ~]#

Step 3. Configure NFS Share Directory: Create a new directory and allow full access to the NFS clients for NFS share configuration:

[root@linuxcnf ~]# mkdir -p /opt/nfsshare
[root@linuxcnf ~]# chown -R nobody: /opt/nfsshare/
[root@linuxcnf ~]# chmod -R 777 /opt/nfsshare/
[root@linuxcnf ~]# ls -ld /opt/nfsshare/
drwxrwxrwx. 2 nobody nobody 1 Sep  1 08:47 /opt/nfsshare/
[root@linuxcnf ~]#

Modify /etc/export configuration and put the following parameters. Change the client address 192.168.1.105 according to environment and access restrictions:

[root@linuxcnf ~]# vi /etc/exports
/opt/nfsshare       192.168.1.105(rw,sync,no_root_squash)
……………………
[root@linuxcnf ~]#

Save the file and export the shared directory for clients using following command:

[root@linuxcnf ~]# exportfs -r
[root@linuxcnf ~]#

Step 4. Firewall Configuration: Configure firewall to allow clients to access NFS Share:

[root@linuxcnf ~]# firewall-cmd --permanent --add-service={mountd,nfs,rpc-bind}
success
[root@linuxcnf ~]# firewall-cmd --reload
success
[root@linuxcnf ~]#

Done!!! NFS File Sharing Server is installed and configured successfully on CentOS8.

NFS client Configuration: Follow the article Howto Mount an NFS Share on CentOS 8 Client machines.

No comments:

Post a comment