The Network File System (NFS) was developed to allow linux machines to mount a disk partition on a remote linux machine as if it were a local disk. It allows for fast, seamless sharing of files across a network.

Note : All the commands are run by root user.

Brief about setup

I have two machine, both are running ubuntu 10.10 desktop edition. I am making one machine as a nfs server & another one as a nfs client

Server Machine

Client Machine

Server side setup

Package installation

apt-get install nfs-kernel-server nfs-common portmap

Starting Services

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

Test whether NFS is running correctly with the rpcinfo command. You should get a listing of running RPC programs that must include mountd, portmapper, nfs, and nlockmgr.

rpcinfo -p localhost

Sharing files / Directories
You have to mention shares & their permission in /etc/exports file. I am sharing my /movies directory with another pc on the network. Giving read only permission to client machine
Edit the file /etc/exports

vi /etc/exports
/movies		*(ro,sync)

If you want to share same folder with read & write permission then syntax will be

/movies		*(rw,sync)

If you want to share same folder only for particular machine on the network then


For more info you can refer man pages for NFS

man 5 exports

Whenever we modify /etc/exports, you must run

exportfs -av
-a     Export or unexport all directories
-v     Be verbose. When exporting or unexporting, show what’s going on.
       When  displaying  the current export list, also display the list
       of export options.

Client side setup

Package installation

apt-get install nfs-common portmap

Starting Services

/etc/init.d/portmap restart

Geting server share information

showmount -e

Mounting The NFS Shares On The Client

mkdir /tp
mount -t nfs /tp

Confirm the share by mount command. You can also add mount entry in fstab file, so that at the next start of your machine you don’t need to manually mount the share.

echo "	/tp	nfs	defaults	0 0" >> /etc/fstab

Note : If you can’t access nfs share from client please ensure that
1. TCP/UDP 2049,111 ports should be open on your firewall.
2. Check the output of rpcinfo command
3. Update the share information via exportfs -av command
4. Reload the service on NFS server as well as NFS client

File sharing in ubuntu with NFS
Tagged on:                                                                                                                                                                                                                                                                                                                                                     

9 thoughts on “File sharing in ubuntu with NFS

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Recommend on Google