About NFS (Network File System) Mounts
NFS mounts allow sharing a directory between several servers. This has the advantage of saving disk space, as the directory is only kept on one server, and others can connect to it over the network. When setting up mounts, NFS is most effective for permanent fixtures that should always be accessible.
An NFS mount is set up between at least two servers. The machine hosting the shared directory is called the server, while the ones that connect to it are clients.
This tutorial will take you through setting up the NFS server.
The system should be setup as root
sudo su -
Setting up the NFS Server
1. Install the required software and start services
First we use yum to install the required nfs programs.
yum install nfs-utils nfs-utils-lib
Now we will run the startup scripts for the NFS Server:
chkconfig nfs on chkconfig portmap on service portmap start service nfs start
2. Export the shared directory
The next step is to make the directory we want to share available to our clients. The chosen directory should then be added to
/etc/exports, which specifies both the directory to be shared and the share permissions.
If we wanted to share the directory
/home we would do the following:
We would edit Exports:
Add the following lines to the file, sharing the directory with the client:
These settings achieve the following:
- rw: This option allows the client to both read and write within the shared directory
- sync: Sync confirms requests to the shared directory only once the changes have been committed.
- no_subtree_check: This option prevents the subtree checking. When a shared directory is the subdirectory of a larger filesystem, nfs performs scans of every directory above it, in order to verify its permissions and details. Disabling the subtree check may increase the reliability of NFS, but reduce security.
- no_root_squash: This phrase allows root to connect to the designated directory
Once completed save the file and exit it, then run the following command to export the settings:
You now have a fully functioning NFS server. If there is anything you think I have missed from this tutorial please comment below.