Quick post on how to setup a NFS Server on Ubuntu and how to setup a mount point on the client side to interact with the NFS Server.
In this post
10.8.133.83 will be the IP of our NFS Server.
$ apt update && sudo apt upgrade -y $ sudo apt-get install nfs-kernel-server nfs-common -y
Create the Directory for NFS and set permissions:
mkdir /vol chown -R nobody:nogroup /vol
Allow Access for the Clients:
We need to set in the
exports file, the clients we would like to allow:
rw: Allows Client R/W Access to the Volume.
sync: This option forces NFS to write changes to disk before replying. More stable and Consistent. Note, it does reduce the speed of file operations.
no_subtree_check: This prevents subtree checking, which is a process where the host must check whether the file is actually still available in the exported tree for every request. This can cause many problems when a file is renamed while the client has it opened. In almost all cases, it is better to disable subtree checking.
$ echo '/vol 10.8.133.83(rw,sync,no_subtree_check) 10.8.166.19(rw,sync,no_subtree_check) 10.8.142.195(rw,sync,no_subtree_check)' >> /etc/exports
Start the NFS Server:
Restart the service and enable the service on boot:
$ sudo systemctl restart nfs-kernel-server $ sudo systemctl enable nfs-kernel-server
We will mount the NFS Volume to our Clients
Install the dependencies:
$ sudo apt-get install nfs-common -y
Test if we can mount the volume, then unmount it, as we will set the config in our
$ sudo mount 10.8.133.83:/vol /mnt $ sudo umount /mnt $ df -h
Set the config in your
fstab, then mount it from there:
$ sudo bash -c "echo '10.8.133.83:/vol /mnt nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0' >> /etc/fstab" $ sudo mount -a $ df -h
Now you shoule be able to write to your NFS Volume on
/mnt from your client.