Bobcares

Install and Configure NFS Server on RHEL/CentOS 8

by | Jan 14, 2021

Install and Configure NFS Server on RHEL 8/CentOS 8  with few quick and easy steps.

At Bobcares, we often get requests from our customers to install  NFS in their server as a part of Server Management Services.

Today let’s see how our Support Techs implement this for our customers in an easy way.

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.

Install and Configure NFS Server on RHEL

Steps to Install and Configure NFS Server on RHEL

We will see the steps that our Support Techs follow 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 server.example.com --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:

1. Manually editing the /etc/exports configuration file
2. 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 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 assistance? We are here for you!]

Conclusion

To conclude we saw how to Install and Configure NFS Server on RHEL along with the steps that our Support Engineers use.


PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.