Note: This is an RHCE 7 exam objective.
Install the NFS packages:
# yum groupinstall -y "file-server"
Add a new service to the firewall:
# firewall-cmd --permanent --add-service=nfs Success
Reload the firewall configuration:
# firewall-cmd --reload Success
Activate the NFS services at boot:
# systemctl enable rpcbind # systemctl enable nfs-server # systemctl enable nfs-lock
Note: With the RHEL 7.3 release, the Systemd init system is able to use aliases. For example, the nfs.service is a symbolic link/alias to the nfs-server.service service file. This enables, for example, using the systemctl status nfs.service command instead of systemctl status nfs-server.service.
Previously, running the systemctl enable command using an alias instead of the real service name failed with an error.
Start the NFS services:
# systemctl start rpcbind # systemctl start nfs-server # systemctl start nfs-lock
Create a directory to export (here /shared):
# mkdir /shared
Create a dedicated group (here called sharedgrp):
# groupadd -g 60000 sharedgrp
Assign this group to the new directory:
# chgrp sharedgrp /shared
# chmod 2770 /shared
Edit the /etc/exports file and add the following lines with the name (or IP address) of the client(s):
Export the directories:
# exportfs -avr # systemctl restart nfs-server
Note1: The client needs to have access to the same group (via LDAP) and be a member of this group.
Note2: The last command shouldn’t be necessary in the future. But, for the time being, it avoids rebooting.
Note3: The standard way to export shares is to create a file finishing by .exports in the /etc/exports.d directory (/etc/exports.d/openshift-ansible.exports for example).