I am a highly skilled and experienced administrator with a strong background in both Windows and Linux systems. I have a deep understanding of network infrastructure, security, and system administration, and am able to effectively troubleshoot and resolve a wide range of technical issues. I am also well-versed in various scripting languages, including PowerShell and Bash, and am able to automate repetitive tasks and improve system efficiency.

Full width home advertisement

Post Page Advertisement [Top]

 


To install and configure an NFS server on Red Hat Enterprise Linux 8, follow these steps:

 

Install the NFS server package:

Copy code

sudo dnf install nfs-utils

Create a directory to be shared over NFS. For example:

Copy code

sudo mkdir -p /var/nfs/share

Modify the permissions and ownership of the directory to allow clients to access it. For example:

Copy code

sudo chmod 777 /var/nfs/share

sudo chown nfsnobody:nfsnobody /var/nfs/share

Edit the /etc/exports file and add a line to export the directory over NFS. For example:

Copy code

/var/nfs/share 192.168.1.0/24(rw,sync,no_subtree_check)

This will allow clients on the 192.168.1.0/24 network to mount the /var/nfs/share directory with read and write permissions. The sync option ensures that data is written to the server's disk before the write operation is considered complete, and the no_subtree_check option disables a performance-enhancing feature that is not needed in most cases.

 

Start the NFS service:

Copy code

sudo systemctl start nfs-server

Enable the NFS service to start automatically at boot:

Copy code

sudo systemctl enable nfs-server

(Optional) If you want to allow clients to mount the NFS share using a hostname instead of an IP address, you can add an entry to the /etc/hosts file on the server. For example:

Copy code

192.168.1.100 nfs-server

This will allow clients to mount the NFS share using the hostname nfs-server.

 

That's it! Your NFS server is now configured and ready to serve exports to clients.

 

 

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.

 

 

===================================================================================

 

2.NFS:

====

Network File System (NFS) is a distributed file system protocol originally developed by Sun Microsystems (Sun) in 1984, allowing a user on a client computer to access files over a computer network much like local storage.

 

NFS4 Configuration in RHEL 8 (CentOS 8):

==================================

 

An acronym for Network File Share, NFS is a cross-platform client/server protocol that allows clients machines to access files shared by the NFS server over a network. Client systems can locally mount the filesystems from the NFS server and access files and directories as though they were locally mounted. In this guide, we will walk you through the installation and configuration of NFS Server on CentOS 8 / RHEL 8.

 

Note: In CentOS 8 or RHEL 8 NFSv3 & v4 both are supported. NFSv3 allows safe asynchronous write and supports 64-bit file sizes & offset. Whereas NFSv4 works through OS firewall and support ACL (Access Control List) and doesn’t require rpcbind service

 

# dnf install nfs-utils -y

# systemctl start nfs-server.service

# systemctl enable nfs-server.service

# systemctl status nfs-server.service

# rpcinfo -p | grep nfs

# mkdir -p /mnt/nfs_shares/docs

# chown -R nobody: /mnt/nfs_shares/docs

# chmod -R 777 /mnt/nfs_shares/docs

# systemctl restart nfs-utils.service

# vim /etc/exports

/mnt/nfs_shares/docs    192.168.2.103(rw,sync,no_all_squash,root_squash)

 

# cat /etc/exports

/mnt/nfs_shares/docs    192.168.2.103(rw,sync,no_all_squash,root_squash)

 

Let’s look at the meaning of the parameters used:

rw  – This stands for read/write. It grants read and write permissions to the NFS share.

sync – The parameter requires the writing of the changes on the disk first before any other operation can be carried out.

no_all_squash – This will map all the UIDs & GIDs from the client requests to identical UIDS and GIDs residing on the NFS server.

root_squash – The attribute maps requests from the root user on the client-side to an anonymous UID / GID.

To export the above created folder, use the exportfs command as shown:

# exportfs -arv

# exportfs -s

# firewall-cmd --permanent --add-service=nfs

# firewall-cmd --permanent --add-service=rpc-bind

# firewall-cmd --permanent --add-service=mountd

# firewall-cmd --reload

 

Client Configuration:

---------------------

# dnf install nfs-utils nfs4-acl-tools -y

# showmount -e 192.168.2.102

# mkdir -p /mnt/client_share

# mount -t nfs 192.168.2.102:/mnt/nfs_shares/docs /mnt/client_share

# mount | grep -i nfs

192.168.2.102:/mnt/nfs_shares/docs  /mnt/client_share  nfs  defaults  0  0

 

Testing NFS Server & Client Setup:

----------------------------------

# touch /mnt/nfs_shares/docs/server_nfs_file.txt

# ls -l /mnt/client_share/

# touch /mnt/client_share/client_nfs_file.txt

# ls -l /mnt/nfs_shares/docs

 

As you can see, you can easily create files on both the NFS server and client and share them seamlessly between the two systems as well as other client systems that have been configured to access the shares. And this brings us to the end of our tutorial today. In this guide, we showed you how to install and setup the NFS server and client system setup on CentOS 8 and RHEL 8.

====

 


No comments:

Post a Comment

Bottom Ad [Post Page]