Sunday, September 13, 2015

How to install NFS server on ubuntu 14.04

NFS ( Network file systems ) is used to share files with other computers over the network.
It is mainly used for centralized home folders. This article explains, how to setup NFS server on ubuntu 14.04 . also explains about mounting nfs shares on client machine .

Setup NFS server on ubuntu 14.04

Step 1 » Update the repositories.
sudo apt-get update

Step 2 » Install nfs server package by typing the command.
sudo apt-get install nfs-kernel-server

Step 3 » Make directory you want to share with other computers.
sudo mkdir /nhome

Step 4 » Here /etc/exports is the main config file for NFS.
Vim /etc/exports

#Share access to all networks
/nhome        *(rw,sync,no_root_squash)
#Share access to particular network
#Share access to particular host
#Share access to all hosts in particular domain
/nhome4       *,sync,no_root_squash)

·         rw: This option gives the client computer both read and write access to the volume.
·         ro:  This option gives the client computer both read-only access to the volume.
·         sync: This option forces NFS to write changes to disk before replying. This results in a more stable and consistent environment, since the reply reflects the actual state of the remote volume.
·         nosubtreecheck: This option 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.
·         norootsquash: By default, NFS translates requests from a root user remotely into a non-privileged user on the server. This was supposed to be a security feature by not allowing a root account on the client to use the filesystem of the host as root. This directive disables this for certain shares.

Step 5 » Start service by the below command.
sudo /etc/init.d/nfs-kernel-server start

Step 6 » Now check the NFS share status.
linux@ubuntu:~$ sudo exportfs -u
/nhome3 *
/nhome world

Ubuntu – Client side

Step 1 » Install nfs client and dependencies .
sudo apt-get install nfs-common rpcbind

Step 2 » Create a directory /rhome .
sudo mkdir /rhome

Step 3 » Mount the remote share /nhome on local directory /rhome.
Temporary mount
sudo mount -t nfs /rhome
add the following line in /etc/fstab file for permanent mount. /rhome nfs rw,sync,hard,intr 0 0

Step 4 » Check the mounted share directory using mount command.
linux@ubuntu:~$ mount
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw) on /rhome type nfs (rw,vers=4,addr=,clientaddr=

Now local rhome is remote NFS directory . whatever data copied to that folder will be stored in remote directory /nhome.

No comments:

Post a Comment