Network File System (nfs) is a distributed file system protocol used to access files over a network. In today’s  blog entry we will look at how to setup an nfs share on a Linux system and then mount it from an nfs client.

The two systems that we will be using today are both running Ubuntu 14.10.

Server Setup

Install the package

sudo apt-get install nfs-kernel-server

Restart nfs on the Server

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

Create the share. In this example we will opt for sharing in standard mode by ensuring it is not owned by anyone or by any group.

If you need to preserve the permissions and ownership of files another option would be to use the no_root_squash option within the exports file which instructs the nfs server to preserve permissions and ownership of the files. You would also need to chmod 777 the  folder so that regular users could create content.

sudo mkdir /media/share
sudo chown nobody:nogroup /media/share

Configure the domain name within /etc/idmapd.conf

sudo nano /etc/idmapd.conf


Now we will export the share within the file /etc/exports.

(Note: newhorizons is the computer we are permitting connections from)

sudo nano /etc/exports

We will add the following line

/media/share newhorizons(rw,sync,no_subtree_check)


Generate the nfs table that holds the  information (aka exports) of your shares by typing

sudo exportfs -a

Restart nfs on the Server

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


Client Setup

Install the nfs client

sudo apt-get install nfs-common

Create the folder you will mount the remote share to

sudo mkdir /media/atlasv

Mount the share

sudo mount atlasv:/media/share /media/atlasv

Show all file systems to confirm the new share shows up

df -h

Show only the nfs shares that are mounted on the system

mount -t nfs

nfs client final

You can statically mount the nfs share by adding the entry to your fstab

sudo nano /etc/fstab


atlasv:/media/share /media/atlasv nfs rw,hard,intr 0 0

By adding your nfs mount information to fstab your client will automatically mount this share anytime it is rebooted.