NFS is an ancient old way of sharing folders on a network . But this is possible on a LINUX only network.And in such a network NFS is always preferred as it has a lot of advantages over samba.NFS is pretty easy to setup in ubuntu linux.Just type in a few commands and a few settings and your done.So here's how you setup NFS in your ubuntu linux machine :

SERVER CONFIGURATION :

Step 1 : Go to the Terminal(Applications->Accessories->Terminal)
Step 2 : And type sudo apt-get install nfs-kernel-server nfs-common portmap to install nfs server
Step 3 : After the installation is done, you need to configure portmap , do this by typing sudo dpkg-reconfigure portmap . Ensure that You Select NO to bind Local loopback Address.

Step 4 : Once thats done, just restart Portmap by typing sudo /etc/init.d/portmap restart


HOW TO SHARE FOLDERS WITH NFS SERVER :

THE COMMAND LINE WAY :

Step 1 : You would need to edit the /etc/exports file for this, so in the terminal type sudo gedit /etc/exports
Step 2 : gedit should open up with the exports file.
Step 3 : Now to add a shared folder say /home/prash/test to be accessible by only one pc say 192.168.1.10 and say it has to be read-write.Then you add the line /home/prash/test 192.168.1.10(rw,no_root_squash,async) to the end of exports file.

If you want to share a folder say /home/prash/test again but this time say you want it to be read only and you want every pc on the network to have access to it, then add the following line /home/prash/test *(ro,async) . * stands for all.

Step 4 : Save the file with all changes and restart nfs server by typing sudo /etc/init.d/nfs-kernel-server restart at the terminal

THE GUI WAY :

Step 1 : This is a pretty easy way, very easy to figure out, right click on a Folder you want to share and click on Share Folder
Step 2 : Then Under Share Through select Unix Networks(NFS) .

Step 3 : Then click on Add , now if you want to specify a hostname or an ip address, you may do so, if you want all pcs on your network to access it, then just leave it blank.Under Host Settings Check or Uncheck Read Only depending on how you want it.

Step 4 : Click On OK . and restart NFS server by typing sudo /etc/init.d/nfs-kernel-server restart at the terminal.

CLIENT CONFIGURATION :

Step 1 : Now once your done with the sharing, you need to configure your client to connect to the shares, Now open your Terminal(Applications->Accessories->Terminal) on the client machine
Step 2 : And type sudo apt-get install portmap nfs-common to install the client
Step 3 : Now you can Mount the folder manually by typing in the commands manually in the terminal itself
Step 4 : Say you want to mount the /home/prash/test folder of the server machine in the /home/user/Desktop/share folder which is in the client machine.In that case, you first need to ensure that the share folder is created in the desktop.Then you type in the following command sudo mount x.x.x.x:/home/prash/test /home/user/Desktop/share .Here in this case x.x.x.x is the ip address or host name of the NFS Server machine
NOTE : To know the ip address of the NFS server machine , type ifconfig in the NFS server machine's terminal.You should typically see an output where there is an ip of the form 192.168.1.x or 192.168.0.x .That would be the NFS server machine's ip.

Now Incase you want your client machine to automatically mount the folder at startup so you dont have to type in the mount command always.Then Do the Following
Step 1 : In your terminal type sudo gedit /etc/fstab
Step 2 : The fstab file should now open in gedit
Step 3 : Now taking the above example in Step 4 , add the following line to the fstab file x.x.x.x:/home/prash/test /home/user/Desktop/share nfs rsize=8192,wsize=8192,timeo=14,intr . You obviously need to edit this line , depending on your situation
Step 4 : Now save this file and you should be good to go!!

NOTE : If you have a firewall installed , then you need to open the following ports 2049,111 and 32771

0 comments

Post a Comment