NFS Server on RHEL/CentOS 8 - Steps to install and configure ?

NFS, or Network File System, was designed in 1984 by Sun Microsystems. This distributed file system protocol allows a user on a client computer to access files over a network in the same way they would access a local storage file. Because it is an open standard, anyone can implement the protocol.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to  install  NFS on Ubuntu / Debian Server.

In this context, we shall look into the steps to install and configure NFS Server on Linux Server.

How to Install and Configure NFS Server on RHEL 8/CentOS 8?

Network File System(NFS) allows client systems to access files that are stored on a remote shared server over a network and lets to make use of those file systems.

NFS is a client-and-server file system(FS).  We can share files with NFS easily between multiple systems on the same network.

Here we will setup NFSv4.2 on our RHEL/CentOS system.

Steps to Install and Configure NFS Server on RHEL

Here, we will follow the steps given below to install and configure NFS.

1. Updating server and setting hostname

We can use the following commands:

$ sudo yum -y update
$ sudo hostnamectl set-hostname --staticM</code?

2. Installing NFS Server on CentOS 8/RHEL 8

First, we can install the NFS server packages on RHEL/CentOS 8 system.

$ sudo yum -y install nfs-utils

Then start and enable nfs-server service.

$ sudo systemctl enable --now nfs-server rpcbind

3. Exporting NFS Shares on RHEL 8/CentOS 8

For configuring exports on an NFS server there are two ways:

i. Manually editing the /etc/exports configuration file

ii. Using the exportfs utility via command line

Syntax rules for /etc/exports configuration file are given below:

1. Blank lines are ignored.

2. Start a line with the hash (#) to add a comment.

3. With backslash (\) wee can wrap long lines.

4. Each exported file system should be on its own individual line.

5. Use space character if any lists of authorized hosts have to be mentioned after an exported file system

6. Options for each of the hosts should be placed in parentheses directly after the host identifier, without any spaces separating the host and the first parenthesis.

The steps to follow are given below:

1. We will take a secondary disk with a capacity of 20 GB. And partition this disk to create a file system on it to use as an NFS share.

$ lsblk | grep sdb
sdb 8:16 0 20G 0 disk

2. Give the following commands to create partition and file system

$ sudo parted -s -a optimal -- /dev/sdb mklabel gpt
$ sudo parted -s -a optimal -- /dev/sdb mkpart primary 0% 100%
$ sudo parted -s -- /dev/sdb align-check optimal 1
$ sudo mkfs.xfs /dev/sdb1

3. After that, we will mount this to  /data directory.

$ sudo mkdir /data
$ echo "/dev/sdb1 /data xfs defaults 0 0" | sudo tee -a /etc/fstab
$ sudo mount -a

We can check if it’s mounted properly with the following command.

$ df -hT | grep /data
/dev/sdb1 xfs 20G 176M 20G 1% /data

Next, we will create a directory on /data/nfshare

$ sudo mkdir /data/nfshare

Now we need to modify /etc/exports to configure NFS share.

The structure of NFS is:

export host(options)

Next we will use the exportfs utility to selectively export directories without restarting the NFS service.

$ sudo exportfs -rav

Finally, we have to allow NFS service in  firewalld.

$ sudo firewall-cmd --add-service=nfs --permanent
$ sudo firewall-cmd --add-service={nfs3,mountd,rpc-bind} --permanent
$ sudo firewall-cmd --reload

4. Mounting NFS Shares on Client Machines

We can mount NFS shares on a client system after the above steps. The client could be a remote system, a Virtual Machine on the same server, or on the same server itself.

[Need urgent assistance to set up NFS on your Server? We are here for you! ]


This article will guide you on the steps to Install and Configure #NFS Server on #RHEL or #CentOS.

The terms client and server are used to describe the roles that a computer plays when sharing file systems. The NFS service enables any given computer to access any other computer's file systems and, at the same time, to provide access to its own file systems.

To install NFS server:

1. Install NFS #Kernel Server. 

2. Create the #Export #Directory. 

3. Assign server access to client(s) through NFS export file. 

4. Export the shared directory. 

5. Open #firewall for the client (s).

Related Post

Keep In Touch

We hope to hear from you.

Accept File Type: jpg,jpeg,png,txt,pdf,doc,docx