Skip to content

Instantly share code, notes, and snippets.

@PhilipSchmid
Created June 18, 2018 15:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PhilipSchmid/f75cb9d22efec9d7e24ade25abe8ecb2 to your computer and use it in GitHub Desktop.
Save PhilipSchmid/f75cb9d22efec9d7e24ade25abe8ecb2 to your computer and use it in GitHub Desktop.
How To Install A NFS Server

How To Install A NFS Server

Based on CentOS 7.

Prerequisites

Disk

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

FirewallD

firewall-cmd --list-all
firewall-cmd --permanent --add-service=nfs
firewall-cmd --reload
firewall-cmd --list-all

Installation

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

Initial Share configuration

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

Verify Setup

netstat -ltu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment