NFS Setup on RHVH
Tags: Hosted Engine, NFS, RHVH, Red Hat, Storage, Virtualization
Chapter 4. Exporting NFS shares Red Hat Enterprise Linux 8 | Red Hat Customer Portal
Create the file system
-
Ascertain the correct disk using:
fdisk -l fdisk <device-id> n #to create a new partition w #write to the partition table
-
Make
xfs
filesystemmkfs.xfs /dev/<device-id>
blacklist { devnode "^sd[a-z]" }
Restart the
multipath
daemon using:systemctl restart mutlipathd
-
Install
nfs-utils
to enable nfs shares:yum install nfs-utils
-
Ascertain that
rpcbind
is running:systemctl status rpcbind
-
If
rpcbind
is not started, start it using:systemctl enable --now rpcbind
-
Enable
nfs-server
systemctl enable nfs-server systemctl start nfs-server
-
Mount the shared partition:
mkdir /storage #create the folder to mount the partition mount -t xfs /dev/<dev-id> /storage
-
Auto-mount partition on startup using
fstab
: /Find the block id of the partition:blkid
-
Note the highlighted UUID which you get, this will be used later
-
Make the following entry in
/etc/fstab
replacing the UUID with the one you found in the previous command:UUID=a94f4872-9607-488b-8661-a7f8d79ea924 /storage xfs defaults 0 2
-
Mount the file system:
mount -a
-
-
To share the mount on nfs, make the following entry in the /etc/exports:
/storage hostname.tld(rw)
IMPORTANT
The format of the
/etc/exports
file is very precise, particularly in regards to use of the space character. Remember to always separate exported file systems from hosts and hosts from one another with a space character. However, there should be no other space characters in the file except on comment lines.For example, the following two lines do not mean the same thing:
/home bob.example.com(rw) /home bob.example.com (rw)
The first line allows only users from
bob.example.com
read and write access to the/home
directory. The second line allows users frombob.example.com
to mount the directory as read-only (the default), while the rest of the world can mount it read/write. -
Restart the
nfs-server
:systemctl restart nfs-server
-
Add firewall rules to enable access from other hosts:
firewall-cmd --permanent --add-service mountd firewall-cmd --permanent --add-service rpc-bind firewall-cmd --permanent --add-service nfs firewall-cmd --permanent --add-port=<mountd-port>/tcp firewall-cmd --permanent --add-port=<mountd-port>/udp firewall-cmd --reload