Search code examples
nfs

Attempt to mount remote nfs only when it is accessed


I'm looking for some way to mount nfs belatedly, only when it is being accessed. The ideal solution would be if I could add an entry to fstab for the remote nfs drive, but only attempt to mount that drive when it is being accessed.

Basically, I don't know when the remote computer will be on, except I do know that if my program is trying to access it, it will be on and accessible. Is there a good way to do this in configuration so I don't need to call a script from my program?

Both machines are running Debian Linux. The nfs server is Wheezy and the client is Sarge.


Solution

  • You can use automount for this. https://help.ubuntu.com/community/Autofs

    The example there shows how to automount an NFS share.