Normally I mount my NFS shares the old way by putting a line in my fstab file.
This does have some drawbacks, particularly when a share is rarely used, or when an NFS server disappears for whatever reason and leaving a hung share.
There is another way to manage your NFS share, and that is using autofs.
autofs is a program for automatically mounting directories on an as-needed basis. Auto-mounts are mounted only as they are accessed, and are unmounted after a period of inactivity. Because of this, automounting NFS/Samba shares conserves bandwidth and offers better overall performance compared to static mounts via fstab.
This article describes configuring autof with indirect mapping. I wrote another article on how to configure direct mapping here
Here's how to get it working.
First up, we need to install autofs from the Ubuntu repositories;
sudo apt-get install autofs
I keep all my mounted filesystems in a directory called /store. Of course you can use what ever directory you like.
autofs will create any mountpoints as they are required, all we need to do is to tell it where to create them.
Edit your auto.master file;
sudo vi /etc/auto.master
Add a line like this;
What that line says is that the directory
/storeis managed by the file
Let's create the
sudo vi /etc/auto.store
I want to mount an export called "archive" which is on the server "nfs". This is the line I enter;
The first word "archive", is the mount point that will be created in the /store directory and the rest is the server name and export.
Make sure you create the store directory;
sudo mkdir /store
sudo service autofs restart
Check to see if it is working;
audio ebooks homes iso lost+found video
For more information on autofs including more detailed technical details, see the documentation here.