Based on CentOS 7.
pvcreate /dev/sdb
vgcreate vg1-nfs /dev/sdb
lvcreate -l 100%FREE -n nfs vg1-nfs
mkfs.xfs /dev/vg1-nfs/nfs
mkdir /nfs
Add the following line to the /etc/fstab
configuration file:
/dev/vg1-nfs/nfs /nfs xfs defaults 0 0
Mount the newly created disk:
mount -a
firewall-cmd --list-all
firewall-cmd --permanent --add-service=nfs
firewall-cmd --reload
firewall-cmd --list-all
This setup is mainly configured based on the official Red Hat documentation: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/nfs-serverconfig#nfs4-only
yum install nfs-utils
systemctl enable nfs
Only allow NFSv4:
sed -i "s/RPCNFSDARGS=.*/RPCNFSDARGS=\"-N 2 -N 3 -U\"/g" /etc/sysconfig/nfs
systemctl mask --now rpc-statd.service rpcbind.service rpcbind.socket
mkdir -p /nfs/my-nfs-share
cat >> /etc/exports <<EOF
/nfs/my-nfs-share 192.168.X.X(rw) 192.168.X.Y(ro)
EOF
Finally restart the NFS service to apply the changes:
systemctl start nfs
netstat -ltu