Sharing Files Using NFS (Linux's Network File System)

This guide shows you how to quickly and easily set up a network share using NFS on Linux.  The share won't be secured in any way, so only use it on a local network - don't share the files with the internet (unless you really want to!)  [For more in-depth instructions, this is quite a good guide]


Firstly install the NFS server:

sudo apt-get install rpcbind nfs-kernel-server

Now add a line to the /etc/exports file - one for each directory you want to share: (the following options are the ones I use, more can be found here).


This shares the files at /media/usbdrive with any computer on the local network (assuming the network is using addresses -

Now "export" the directories, and restart the NFS service:

sudo exportfs -ra
sudo service nfs-kernel-server restart


Install the NFS client:

sudo apt-get install rpcbind nfs-common

Now create a local directory to mount the remote directory into, e.g.:

mkdir -p ~/media/nfsdrive

And mount the files (substituting the correct IP address for the server, and remote/local paths appropriately):

sudo mount -t nfs /home/username/media/nfsdrive

To unmount, simply use:

sudo umount /home/username/media/nfsdrive