Easy Steps to set up NFS in your Computer or Server Network

Network File System [NFS] is a very effective way of sharing files and data across your Unix/Linux network. NFS offers a neat functionality that fits perfectly into the Unix/Linux filesystem. Simply mount a directory off another machine on your network and read from or write to it; even run applications from it, that’s completely transparent!

Following are the steps to achieve NFS facility in your network.

You need to set up two kinds of services of NFS that is NFS Server at file sharing server and NFS Clint at Clint or user side servers.
[ad#add-top-in]
Setting Up an NFS Server:

-Install NFS-Server application in servers which ever you want to share. Using following commands.

apt-get install nfs-kernel-server
or
yum install nfslock portmap nfs

-Place an entry in /etc/exports

/usr/local   192.168.0.1(ro) 192.168.0.2(ro)
/home      192.168.0.0/255.255.255.0(rw)

Here we are sharing ‘/usr/local’ with read-only and ‘/home’ with write permission. We can also specify network mask for allowing a group of network computers  or each IP as shown above to allow specified IP to access this folders.

-If you come back and change your /etc/exports file, the changes you make may not take effect immediately. You should run the command ‘exportfs –ra’ to force
nfsd to re-read the /etc/exports file.

-You may need to set /etc/hosts.allow and /etc/hosts.deny
These two files specify which computers on the network can use services on your machine. Each line of the file contains a single entry listing a service and a set of machines. When the server gets a request from a machine, Its not compulsory if your are not using it.

-The NFS server is configured and we can start it running.

/etc/init.d/nfs-kernel-server stop
/etc/init.d/nfs-kernel-server start

Now we have setup NFS Server to share or get the shared NFS files. We need to set up following steps in Clint servers or PC

Setting up an NFS Client:

-Install NFS-Clint application in servers. Using following commands for this.

apt-get install nfs-common
or
yum install nfslock portmap nfs

-Mount the remote directory from your server just the way you mount a local hard drive, with the mount command.

mount 192.168.0.10:/home /mnt/home

Make sure you have created ‘/mnt/home’ directory before mounting it.

-To un-mount you need to run following command

umount /mnt/home

-NFS file systems can be added to your /etc/fstab file, same way as local file systems, so that nfs mounts when your system starts up. For this you need to enter following entry in fstab.

192.168.0.10:/home  /mnt/home    nfs          rw            0    0

These are the simple steps to set up NFS mount; there are lots of options and steps and configurations to set NFS in little more effective manner, also can set fstab and export file configurations for more flexible NFS functionality.