Deploying NFS Share at a node - SeaDataCloud/Documentation GitHub Wiki
These are the steps to setup an NFS Share between the different Virtual Machines in a given site. This shared volume/space is used to synchronise user data between the different applications.
Steps:
Setting up the server
1. Install NFS Utils in the machine
yum -y install nfs-utils
2. Exporting directories from the server
Make share directory(ies)
mkdir /nfs
chown nfsnobody:nfsnobody /nfs
chmod 755 /nfs
Next, modify the exports
file to provide information on the NFS share
vim /etc/exports
Insert the below line
/nfs *(rw,sync,no_subtree_check,no_root_squash)
(The no_root_squash option makes sure that /nfs will be accessed as root)
After modifying exports
file, always run the below command
exportfs -a
Setting up the client
1. Install NFS Utils in the machine
yum -y install nfs-utils
2. Create directories to mount the shared volume
mkdir -p /mnt/nfs
3. Mount the NFS shared volume
mount -t nfs -vvvv <IP_address_of_NFS_server>:/nfs /mnt/nfs
The -vvvv
tag helps to mount in a verbose fashion. This can be omitted if needed.
Confirm the mount by one of the below commands
df -h
or
mount
The output should look something like this (for df -h
)
<IP_address_of_NFS_server>:/nfs 160G 33M 160G 1% /mnt/nfs
4. Mount NFS share at boot time
This is done by modifying /etc/fstab
. Working with /etc/fstab
is really dangerous as the file itself is critical for the proper function of the OS. So, proceed with caution!.
Edit /etc/fstab
by
vim /etc/fstab
Add the following line to the bottom of the file (DO NOT CHANGE anything else)
<IP_address_of_NFS_server>://nfs /mnt/nfs nfs defaults,_netdev 0 0
To test if the change made in the /etc/fstab
is working
reboot
When you log back in, do
df -h
and look for a similar line:
<IP_address_of_NFS_server>:/nfs 160G 33M 160G 1% /mnt/nfs
Testing
On client
touch /mnt/nfs/test.txt
On server
ls -l /nfs
Should show a similar result:
-rw-r--r-- 1 root root 0 Oct 9 14:02 test.txt