Linux serverNETWORK ADMINISTRATIONS

Configure NFS Server in RHEL 8 | NFS4 Configuration in Linux in Hindi | Nehra Classes

Install & Configure NFS SERVER ON RHEL 8:
———————————————————————–

This guide will explain how to install NFS server on RHEL 8 / CentOS 8 Linux server. NFS stands for Network File System. It enables client systems to access files that are stored on a remote shared server over a network and make use of those file systems as if they are locally mounted. NFS is a client-and-server file system (FS).
By using NFS shared storage, system administrators can consolidate resources onto centralized servers on the network. Files are easily shared between multiple systems on the same network. A client system can access the remote share with (read, write) privileges and do not have access to the underlying block storage.
Supported NFS versions
Below are the versions of NFS supported by RHEL 8.
NFS version 3 (NFSv3)
• Has support for safe asynchronous writes and is more robust at error handling than the previous NFSv2
• Supports 64-bit file sizes and offsets, allowing clients to access more than 2 GB of file data.
NFS version 4 (NFSv4)
• Works through firewalls and on the Internet
• No longer requires rpcbind service
• Supports Access Control Lists (ACLs)
• Utilizes stateful operations.
In this guide, we will setup NFSv4.2 on our RHEL/CentOS system. Here is my setup design.
Server Type OS IP Hostname
NFS Server RHEL/CentOS 8 192.168.1.108 RHEL8.NehraClasses.com
NFS Client 1 RHEL/CentOS 7 192.168.1.107 RHEL7.NehraClasses.com

But note that the configuration of NFS client will be covered in a separate guide. Follow the steps below to install NFS Server on CentOS 8 / RHEL 8 Linux system.
Step 1: Update server and set hostname
Your server should have a static IP address and static hostname that persists reboots. Check our guides on how to set static IP on RHEL/CentOS 8.
sudo yum -y update
sudo hostnamectl set-hostname server.example.com –static
Step 2: Install NFS Server on CentOS 8 / RHEL 8
Next is the installation of the NFS server packages on RHEL / CentOS 8 system.
sudo yum -y install nfs-utils
After the installation, start and enable nfs-server service.
sudo systemctl enable –now nfs-server rpcbind
Status should show “running“.

Step 3: Exporting NFS Shares on RHEL 8 / CentOS 8
There are two ways to configure exports on an NFS server.
1. Manually editing the /etc/exports configuration file
2. Using the exportfs utility on the command line

For this setup, I added a secondary disk to my server with a capacity of 20 GB. We will partition this disk and create file system on it for use as NFS share.
$ lsblk | grep sdb
sdb 8:16 0 20G 0 disk

# Create partition and file system
I’ll create directory on /data/nfshare that will be exported to NFS clients.
sudo mkdir /data/nfshare
Now we need to modify /etc/exports to configure NFS share. The structure is:
export host(options)
It is also possible to specify multiple hosts, along with specific options for each host, like below.
export host1(options1) host2(options2) host3(options3)
Where:
• export is the directory being exported
• host is the host or network to which the export is being shared
• options List of options to be used for the host
In my setup, I’ll give the exported file system is read & write permissions to allow remote hosts to make changes to the data shared on the file system. My host will be a network 192.168.1.0/24.
So my line on /etc/exports file will be.
/data/nfshare 192.168.1.0/24(rw,no_root_squash)
The no_root_squash option disables root squashing – enables remote root user to have root privileges. This is usually required for VM installations on NFS share.
export directories without restarting the NFS service.
$ sudo exportfs -rav
exporting 192.168.1.0/24:/data/nfshare
• r – Causes all directories listed in /etc/exports to be exported by constructing a new export list in /etc/lib/nfs/xtab
• a – All directories are exported or unexported, depending on what other options are passed to exportfs
• v – Verbose operation – Show what’s going on
If Firewalld is running, allow NFS service.
sudo firewall-cmd –add-service=nfs –permanent
sudo firewall-cmd –add-service={nfs3,mountd,rpc-bind} –permanent
sudo firewall-cmd –reload
SELinux boolean may need to be enabled.
sudo setsebool -P nfs_export_all_rw 1
Step 4: Mounting NFS Shares on Client Machines
Now that we’re done with NFS server configurations, the remaining part is mounting NFS shares on a client system.
Create a directory named as data on / at the client side.
# mkdir /data
Now mount the nfs share on this newly created directory (i.e. data)
# mount -t nfs 192.168.1.108://nfshare/data /data

You have now successfully created the network file system (NFS) and mount it on Client machine.
————————————————————————————————————–
Reference:
computingforgeeks.com website:
https://computingforgeeks.com/install-and-configure-nfs-server-on-centos-rhel/

source

redhat linux

Leave a Reply

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