Friday, 21 February 2014

NFS4 share configuration in Ubuntu


NFS is a service used to share a folder or a directory  located on one networked computer with other computers/devices on that network. It is a native Linux/ Unix protocol unlike samba, which can be shared both in windows and Linux

In NFS version 4 , there is a concept called pseudo file system.

That is there is a directory called /exports which is shared as pseudo file system and all of the directories in the server can be shared by binding it inside the /exports file system

/exports file system can be mounted using the command

mount -t nfs shareip:/ /mnt

That is there is no need to give the share name /exports on mounting it.

Also we can bind any directory inside the /exports folder and can be shared via nfs version4

Below is the steps to configure it

apt-get install nfs-kernel-server

Above command will install the required packages to run nfs server on ubuntu

In NFS 4 all of the directories we are going to share will exist inside a single pseudo file system

All of the directories can be shared under that pseudo file system using --bind option

Let's say we want to export our users' home directories in /home/users. First we create the export filesystem:

mkdir -p /export/users 
Now we will bind the /home/users directory inside the /export as

mount --bind /home/users /export/users
Also add it on /etc/fstab

/home/users /export/users none bind 0 0

Now open the configuration file /etc/exports and add the following shares as given below

/export,fsid=0,insecure,no_subtree_check,async) /export/users,nohide,insecure,no_subtree_check,async)

That is we are exporting the share to subnet
Once it is done we can start the nfs kernel service using the below command

# service nfs-kernel-server restart
On the client side install package called

apt-get install nfs-common

Once it is done try to mount the nfs share using the command below

mount -t nfs shareip:/ /mnt

mount -t nfs shareip:/users /mnt/users


No comments:

Post a Comment