Setup 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 machines (Centos and ubuntu).

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 /shome
Step 4 » Here /etc/exports is the main config file for NFS.
See the below examples and add share directories to the config file based on your requirement.

#Share access to all networks
/shome        *(rw,sync,no_root_squash)
#Share access to particular network
/shome1       192.168.1.1/24(rw,sync,no_root_squash)
#Share access to particular host
/shome2       host.example.com(rw,sync,no_root_squash)
/shome3       192.168.1.200(rw,sync,no_root_squash)
#Share access to all hosts in particular domain
/shome4       *.krizna.com(rw,sync,no_root_squash)

Step 5 » Start service by the below command.
sudo /etc/init.d/nfs-kernel-server start
Step 6 » Now check the NFS share status.
krizna@leela:~$ sudo exportfs -u
/shome1 192.168.1.1/24
/shome2 192.168.1.200
/shome3 *.krizna.com
/shome world

That’s it .. NSF server config is over .. Continue for Client setup.

Ubuntu – Client

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 /shome on local directory /rhome.
sudo mount 192.168.1.10:/shome /rhome
add the following line in /etc/fstab file for permanent mount.
192.168.1.10:/shome /rhome nfs rw,sync,hard,intr 0 0
Step 4 » Check the mounted share directory using mount command.
krizna@client:~$ mount
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw)
192.168.1.10:/shome on /rhome type nfs (rw,vers=4,addr=192.168.1.10,clientaddr=192.168.1.201)

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

Centos – Client

The below steps can be used on REDHAT and Fedora .
Step 1 » Install nfs client and dependencies
yum install nfs-utils nfs-utils-lib
Step 2 » Create a directory /rhome .
mkdir /rhome
Step 3 » Mount remote NFS share directory shome on rhome local directory.
mount 192.168.1.10:/shome /rhome
add the following line in /etc/fstab file for permanent mount.
192.168.1.10:/shome/ /rhome/ nfs rw,sync,hard,intr 0 0
File will looks like

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
192.168.1.10:/shome/    /rhome/                nfs     rw,sync,hard,intr 0 0

Step 4 » Check the mount status by the below command.
[root@client ~]# mount
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
192.168.1.10:/shome on /rhome type nfs (rw,vers=4,addr=192.168.1.10,clientaddr=192.168.1.200)

Now local rhome is remote NFS directory . whatever data copied to that folder will be stored in remote directory /shome.
Reference : NSF setup on ubuntu 14.04

Be the first to comment

Leave a Reply

Your email address will not be published.


*