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 IP 192.168.1.1 Client Machine IP 192.168.1.3
Server side setup
apt-get install nfs-kernel-server nfs-common portmap
/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
If you want to share same folder with read & write permission then syntax will be
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
-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
apt-get install nfs-common portmap
Geting server share information
showmount -e 192.168.1.1
Mounting The NFS Shares On The Client
mkdir /tp mount -t nfs 192.168.1.1:/movies /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 "192.168.1.1:/movies/ /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