RSS Feed

Mount NFS from server to client

Many projects I tend to work on require mounting of directories over a network in order to propagate static data in a load balanced, redundant environment. This howto details how to configure an NFS server and mount a directory on a client.

NFS server (
Configuring a server to act as an NFS server is simple. First update your repositories:

sudo apt-get update

Then install the required services for the NFS service to function correctly:

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

Once installed, configure portmap. It’s important that you select “No” when specifying if you should bind portmap to the loopback ( address.

sudo dpkg-reconfigure portmap

Reconfiguring portmap should re-start the service for you, however if it doesn’t, do so yourself:

sudo /etc /init.d/portmap restart

Setup the directory you would like to share on the server (
First, as root, open the /etc /exports file and add an entry to the directory you would like mountable on the client server(s).

sudo vi /etc /exports

Adding an entry is pretty simple, the syntax is as follows:

/directory IP_ALLOWED_ACCESS(option,option)



This example will give the machine with the IP of read and write access to /directory. Options wise rw indicates read and write access, no_root_squash will result in root users reading/writing as the root user on the NFS server – only do this in a trusted environment.

Async usually improves performance as you can read and write at the same time, however, crashing of the server could result in data loss or corruption. For this reason I tend to select sync in a production environment.

Find below an example I would use in a production environment that needed to read and write to the directory mount:


Once you have done editing /etc /exports you will need to re-sync the NFS mount list using the following command.

sudo exportfs -a

The -a option specifies to export all currently un-exported directories.

Note: If you do not supply no_subtree_check or subtree_check as an option you will get a warning stating that it will use no_subtree_check. To prevent this message appearing simply add no_subtree_check as an option.

Remember, any changes you make, rerun exportfs -a.

Setup the NFS client (
Like with the NFS server, update your repository data:

sudo apt-get update

And then install the required services:

sudo apt-get install nfs-common portmap

Now, before you can mount the export you have setup you will need to create a mount point.

sudo mkdir /mnt/server1

And now you can mount the directory on the command line:

sudo mount /mnt/server1

To make sure the NFS mount is mounted at boot add a mount line to /etc /fstab.


Example: /mnt/server1 nfs rw,hard,intr

The hard options tells programs using a file via the NFS mount to stop and wait for the NFS server to come back online if connectivity is lost. Soft on the other hand tells the program to report an error as apposed to waiting for connectivity to return.

The intr option allows NFS requests to be interrupted if the hard option is specified and the NFS mount loses connectivity. Specifying hard without intr will result in not being able to terminate the program or service waiting on the NFS connectivity to return.

Note: To make sure the NFS mount is mounted after reboot simply unmount the NFS mount point:

sudo umount /mnt/server1

Then use mount -a to mount all unmounted devices specified in /etc /fstab (In this case it will be the NFS mount)

sudo mount -a

If the NFS mount is mounted it will do so upon booting of the server.

That’s it and yes, it is that simple.

Posted in Linux on the 22nd October 2010


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