How to Setup NFS in Ubuntu

This tutorial shows step-by-step how to setup NFS (Network File System).
Use this tutorial in conjunction with my YouTube video: How to Setup NFS File Shares in Ubuntu


NFS Server

Install NFS Package on your Ubuntu Server

sudo apt-get install nfs-kernel-server

Create Folder List to Share

This example I will be sharing my whole RAID folder with any user (except root) in my LAN.

sudo nano /etc/exports

Add the following line to the end of the exports file.
The spacing is very important, e.g. there is no space between the IP address and Options list.

/mnt/raiddisk	192.168.1.0/255.255.255.0(rw,sync,root_squash,subtree_check)

Start NFS Service

sudo service nfs-kernel-server start

If all is well you will see the message:

* Exporting directories for NFS kernel daemon...      [ OK ]
* Starting NFS kernel daemon                          [ OK ]

Otherwise if there is an error you can stop the NFS service, and then go back and edit the Export list.

sudo service nfs-kernel-server stop

NFS Clients

Install NFS Client Package

sudo apt-get install nfs-common

Create Mount Point

You could either create a mount point under the /mnt folder, or use your home folder.
Here is how to create a folder under /mnt:

sudo mkdir /mnt/nfsmount

Edit fstab

(Substitute nano for your favorite text editor)

sudo nano /etc/fstab

Add the following line to the end of the fstab file:

ServerIP:/ServerFolder	ClientFolder	nfs	Options	dump	pass

For Example:

192.168.1.100:/mnt/raiddisk	/mnt/nfsmount	nfs	rw,soft,intr,noatime,timeo=100,rsize=32768,wsize=32768	0	2

Options List:

Further information is available from the man page

Now to Try it out

sudo mount -a

If all being well you won't see any messages
You only need to use mount -a once, next time you reboot your system will automatically mount the NFS File Share.



Back