Installing and Configuring NFS server

http://www.itzgeek.com/how-tos/linux/centos-how-tos/how-to-setup-nfs-server-on-centos-7-rhel-7-fedora-22.html


yum install nfs-utils 
The following services are found in the nfs-utils package and will be used throughout the installation guide

Service Description
nfs-server Enabled the clients to access NFS server
rpcbind Converts RPC program numbers into universal addresses
nfs-lock / rpc-statd NFS file locking. Implemented file lock recovery when an NFS server crashes and reboots
nfs-idmap Translates user and group ids into names, and vice-versa

Installing (CentOS 7)

systemctl enable rpcbind
systemctl enable nfs-server

systemctl start rpcbind
systemctl start nfs-server
systemctl start rpc-statd
systemctl start nfs-idmapd

Creating NFS Share

mkdir -p /nfs/export1
Now we need to edit /etc/exports to allow for other devices to mount. You will need to replace x.x.x.x with the ip address of the server you wish to allow to connect
vim /etc/exports
/nfs/export1 x.x.x.x(rw,sync,no_root_squash)

no_root_squash : By default, any file request made by user root on the client machine is treated as by user nobody on the server. (Exactly which UID the request is mapped to depends on the UID of user “nobody” on the server, not the client.) If no_root_squash is selected, then root on the client machine will have the same level of access to the files on the system as root on the server.


Once you have edited the /etc/exports file you will need to push these changes through:

exportfs -r

Firewall configuration

firewall-cmd --permanent --zone public --add-service mountd
firewall-cmd --permanent --zone public --add-service rpc-bind
firewall-cmd --permanent --zone public --add-service nfs
firewall-cmd --reload