Whenever you’re using NFS mount points, it’s really nice to use some type of automounter. Linux and FreeBSD use AMD to accomplish this, but Solaris uses automountd, and it’s fun and easy to use… Here is an example of a configuration that will automatically mount an NFS share and unmount it after 5 minuets of inactivity.
We have a system called micky which has an NFS point shared to a system called minny as /shareme.
We can see that it is set up in the /etc/dfs/dfstab file on micky:
share -F nfs -o ro=minny.yourdomain.com -d “NFS ShareMe” /shareme
The above will share the directory read-only. If you would like to map the directory as root and be able to write to it, the command would look more like this:
share -F nfs -o rw,root=minny.yourdomain.com -d “NFS ShareMe” /shareme
You can run the share command on micky to check to make sure it is shared:
# share
- /shareme ro=minny.yourdomain.com “NFS ShareMe”
If it’s not shared, run shareall to share it:
# shareall
Now, jump on over to minny and add the following line to /etc/auto_master:
/- auto_direct
Automountd will now look in /etc/auto_direct for direct mount points.
Next edit /etc/auto_direct and add the following line:
/micky-shareme micky:/shareme
Now, create the directory for the NFS mount point on minny:
# mkdir /micky-shareme
Finally, run the auromount command on minny to inform the daemon of the changes:
# automount
That should do it… Have fun with your new automount NFS share.
More information on this can be found here
How would you set up NFS shares such that any dependencies (resulting from the need to have the sharing server boot up before the mounting server in the event of a restart) are removed? I dealt with this by putting an entry like this in root’s crontab (Fedora Linux): “0 * * * * mount -a -t nfs”
Oh, and of course, I put the appropriate entry in /etc/fstab, enabling the command above to work.