How to configure an NFS server and mount NFS shares on Ubuntu 14.10
Author: Srijan Kishore <s [dot] kishore [at] ispconfig [dot] org>
Follow howtoforge on Twitter
Last edited 26/Nov/2014
This guide explains how to configure an NFS server in Ubuntu 14.10 Network File System (NFS) is a popular distributed filesystem protocol that enables users to mount remote directories on their server. The system lets you leverage storage space in a different location and write onto the same space from multiple servers in an effortless manner. It, thus, works fairly well for directories that users need to access frequently. This tutorial explains the process of mounting NFS share on an Ubuntu 14.10 server in an simple and easy-to-follow steps.
1 Preliminary Note
I have fresh installed Ubuntu 14.10 server, on which I am going to install the NFS server. My Ubuntu server have hostname server1.example.com and IP as 192.168.0.100
You can have your Ubuntu server installed from the tutorial. Alternatively we need a Ubuntu 14.10 client machine either server/desktop. I my case I will use an Ubuntu 14.10 desktop with hostname client1.example.com and IP as 192.168.0.101
2 At NFS server end
Now we will install these packages at the Ubuntu 14.10 server end as:
apt-get install nfs-kernel-server
mkdir /var/nfsshareChange the ownership of the folder as follows:
chown nobody:nogroup /var/nfsshareWe have used /var/nfsshare as, if we uses any other drive such as any /home directory then it will cause a massive permissions problem and ruin the whole hierarchy. If in case we want to share the /home directory then permissions must not be changed.
Now we will share the NFS directory over the network a follows:
We will make two sharing points /home and /var/nfs. Edit it as follows:
/var/nfsshare 192.168.0.101(rw,sync,no_subtree_check) /home 192.168.0.101(rw,sync,no_root_squash,no_subtree_check)
Note 192.168.0.101 is the IP of client machine, if you wish that any other client should access it you need to add the it IP wise other wise you can add "*" instead of IP for all IP access.
Condition is that it must be pingable at both ends.
Next we will update the NFS table with the new sharing points.
Finally start the NFS service as follows:
service nfs-kernel-server start
Now we are ready with the NFS server part.
3 NFS client end
In my case I have the client as Ubuntu 14.10 desktop. Other Ubuntu versions will also work for the same. Install the packages as follows:
sudo apt-get update
sudo apt-get install nfs-common
Now create the NFS directory mount point as follows:
sudo mkdir -p /mnt/nfs/home
sudo mkdir -p /mnt/nfs/var/nfsshare
Next we will mount the NFS shared content in the client machine as shown below:
mount -t nfs 192.168.0.100:/home /mnt/nfs/home/
It will mount /home of NFS server. Next we will /var/nfsshare mount as follows:
mount -t nfs 192.168.0.100:/var/nfsshare /mnt/nfs/var/nfsshare/
Now we are connected with the NFS share, we will crosscheck it as follows:
mount -t nfs
[email protected]:~# mount -t nfs
192.168.0.100:/home on /mnt/nfs/home type nfs (rw,vers=4,addr=192.168.0.100,clientaddr=192.168.0.101)
192.168.0.100:/var/nfsshare on /mnt/nfs/var/nfsshare type nfs (rw,vers=4,addr=192.168.0.100,clientaddr=192.168.0.101)
So we are connected with NFS share.
Now we will check the read/write permissions in the shared path. At client enter the command:
Next check the permissions of the file created there.
ls -l /mnt/nfs/var/nfsshare/
File created have permissions as nobody/nogroup as updated over the NFS-server end.
4 Permanent NFS mounting
We need to mount the NFS share at client end permanent that it must be mounted even after reboot. So we need to add the NFS-share in /etc/fstab file of client machine as follows:
Add the entries like this:
192.168.0.100:/home /mnt/nfs/home nfs defaults 0 0 192.168.0.100:/var/nfsshare /mnt/nfs/var/nfsshare nfs defaults 0 0
Note 192.168.0.100 is the NFS-share IP address, it will vary in your case.
This will make the permanent mount of the NFS-share. Now you can reboot the machine and mount points will be permanent even after the reboot.
Next make the drives active by giving input as:
If we want to add the command in boot startup, so we will add the entries in the file /etc/rc.local as:
and add the entries as follows:
mount -a exit 0
It will enable the command for boot also. Cheers now we have a successfully configured NFS-server over Ubuntu 14.10 :)
- Ubuntu : http://www.ubuntu.com/