Setup NFS server and configure NFS mount point on Ubuntu
Date Posted: 28-02-2017
NFS(Network File system) used to mount remote files to the server. In this post, we will cover up on how to setup NFS server and mount the NFS directory to the client server.
1. Ubuntu Server. One server is Ubuntu Server used for NFS server and second ubuntu server is used to mount the NFS point.
We will start with building NFS server. Let’s start by installing NFS server on the server.
apt-get install nfs-kernel-server
Create a directory for nfs mount point.
Change the ownership and groupname of the directory.
chown nobody:nogroup /nfsshare
Open the file /etc/exports file and add the following line.
220.127.116.11/8 – We can replace this IP address with the IP address which we will be connecting. We can mention either single IP address or IP address range.
rw – this option is used to read write files on the client machine.
sync – This option forces nfs to write changes before sending data.
no_root_squash – This was intended as security feature to prevent a root account on the client from using the file system of the host as root
no_subtree_check – This option disables subtree checking. If a subdirectory of a filesystem is exported, but the whole filesystem isn’t then whenever a NFS request arrives, the server must check not only that the accessed file is in the appropriate filesystem (which is easy) but also that it is in the exported tree (which is harder). This check is called the subtree_check.
Start the nfs server service.
systemctl restart nfs-kernel-server
Client Side NFS Configuration:
So, far we have installed NFS server. Now, its time to mount the partition to the client machine.
Install the nfs-common on the client machine.
apt-get install nfs-common
As an example, we are going to create a directory called /nfs and mount to nfs drive from remote server.
mount -t nfs xx.xx.xx.xx:/nfsshare /nfs
xx.xx.xx.xx is the nfs server IP address.
Make a permanent entry on /etc/fstab so that it automatically mounts whenever the boots up.
xx.xx.xx.xx:/ /nfs nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
Execute the command df -h to view the mounted partition
To unmount the partition, use the below command
Since we already added the mount partition on fstab, it will automatically mount the partition. Test the same by using mount -a command