Thursday, March 7, 2013

Setup NFS (Network File System) on Ubuntu 10.04 LTS

NFS allows a system to share directories and files with others over a network. By using NFS, users and programs can access files on remote systems almost as if they were local files.

Some of the most notable benefits that NFS can provide are:

  • Local workstations use less disk space because commonly used data can be stored on a single machine and still remain accessible to others over the network.

  • There is no need for users to have separate home directories on every network machine. Home directories could be set up on the NFS server and made available throughout the network.

  • Storage devices such as floppy disks, CDROM drives, and USB Thumb drives can be used by other machines on the network. This may reduce the number of removable media drives throughout the network.

In this post I will show you how to setup NFS on ubuntu 10.04.

Experimental Setup: For demonstration of nfs. My experimental setup includes software such as- Oracle VirtualBox, Ubuntu 10.04 iso image. I have window 7 as host operating system. I install two virtual ubuntu 10.04 using oracle virtualbox. So now i have two ubuntu machines running on Oracle virtual box. Both machines are accessible to each other on network.

On Server Side:

Start the server ubuntu machine.

1. First of all install nfs kernel. Internet is required for this.

sudo apt-get install nfs-kernel-server

2. Make directory you want to mount. Always create a new directory never mount your operating system base directories.

sudo mkdir –p /export/users

3. Change mode of these directories so that anyone can read this directory. Change mode according to your need. I am changing it to 777 as least secure.

sudo chmod 777 /export
sudo chmod 777 /export/users

4. Now if you want to share any base operating system folder you can bind it with mounted folder.(server is name of my machine)

sudo mount --bind /home/server /export/users

5. Above binding will be removed when you restart your system. To keep this binding permanently open

sudo nano /etc/fstab

add following line

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

6. Now open-

sudo nano /etc/default/nfs-kernel-server

change or make

NEED_SVCGSSD = no

7. Now open

sudo nano /etc/default/nfs-common

make or change

NEED_IDMAPD = yes
NEED_GSSD = no

8. make sure value in /etc/idmapd.conf following lines are there.

cat /etc/idmapd.conf

check:

Nobody_user = nobody
Nobody_group = nogroup

9. Most important step add this mounted folder in export file. (192.168.80.136 is my server ip)

Open

sudo nano /etc/exports

add following lines at the end

/export         192.168.80.136/24(rw,fsid=0,insecure,no_subtree_check, async)
/export/users   192.168.80.136/24(rw,nohide,insecure,no_subtree_check,async)

10. Now restart the nfs kernel.

sudo /etc/init.d/nfs-kernel-server restart

On client Side:

1. Install nfs common on client side. It requires Internet Connection.


sudo apt-get install nfs-common


2. Open


sudo nano /etc/default/nfs-common


Set:


NEED_IDMAPD = yes
NEED_GSSD = no


3. Now mount the exported folder.


sudo mount –t nfs4 –o proto=tcp, port=2049 192.168.80.136:/ /mnt


mnt is folder created on client side where all files will be mounted.


That's all your nfs is complete.


Error:


If following error came.


mount.nfs4: No such device


you have to load modprobe module by following command.


sudo modprobe nfs


No comments:

Post a Comment