Setup NFS Server on Centos 7

      No Comments on Setup NFS Server on Centos 7
nfs server centos

Introduction

NFS stands for Network File System, a distributed filesystem protocol that enables users to mount remote filesystems onto their server. In this guide we’ll be using RedHat centos 7 server.

Update and Install Necessary packages

Configure disk(s) to be used as NFS storage

In our case we’ll be using two block devices i.e /dev/sdb and /dev/sdc

Run lsblk command to view the list of available devices. We’ll merge the two block devices into a RAID 0 array (Not recommended). This is just for tests purposes. in production environment, consider using a RAID configuration the ensures disk redundancy e.h RAID 6, RAID 6, RAID 10 e.t.c

Convert the disks to GPT and create Partions

To make it easier, we’ll write a short bash script perform this action on our behalf. Converting the disks to GPT removes the 4 primary partions limit enforced by MBR.

Create a file and name it mklabel.sh

Add the following to the file. Edit the device names to suite your environment.

CAUTION: DO NOT INCLUDE THE BOOT DISK HERE!

Make the file executable

Run the script and run lsblk command to confirm the disks

Configure the devices as a RAID 0 array using mdadm

Run lsblk

As shown, the two devices are now in a RAID 0 array i.e md0

Create a file system on the block device. In our case we’ll use xfs

Create a directory to mount the file system

Update /etc/fstab and mount the md0 device to the nfs directory

Mount the file system

Run df command to confirm the mount

 

NFS Exports

Next step is to add the exports

In this case, the IP 192.168.50.41 is our NFS client that will mount the NFS storage. you can also use an asterik (*) if you need any client to mount the storage.

start nfs server

Run the exportfs command

 

Add ports to the firewall and configure selinux

Before concluding, note that Redhat/Centos have a strict firewall policy. Any service accessed that need to be accessed from outside needs to be added to the firewall.

Set selinux to permissive

Add services to the firewall and reload

NFS server is now ready to be used.

Next we’ll look at how to configure NFS client on Centos 7.

The following two tabs change content below.

harun

Harun is a System Administrator with proficient knowledge in cloud technologies such as KVM, Cloudstack, Citrix Xen Server, Openstack and VMware Vsphere Suite, Ceph, NFS, ISCSI

Latest posts by harun (see all)

About harun

Harun is a System Administrator with proficient knowledge in cloud technologies such as KVM, Cloudstack, Citrix Xen Server, Openstack and VMware Vsphere Suite, Ceph, NFS, ISCSI

Leave a Reply

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