We are using autofs to mount an NFS partition from a local server. We have a redundant server and we are failing over to this using the method mentioned in that autofs(5) man page. This is all working fine. What we would like to do is add a third failover to a mountpoint that is determined by a script, denoted by the "program:/path/to/script" in auto.master.

The reason for this is that we are keeping a redundant copy of some software tools that are stored far from our site on slow servers on local fast servers. We want to use these local servers predominantly, but then if neither of them is available, failover to the slow server. The mountpoints of the remote servers are controlled via a script, and may be changed without our knowledge, so we can't simply add another host to the redundant list.

Does anyone know if this can be done and how?


one quick and dirty way I think of off the top of my head is like this:


timeout 5 ls /NFS_mountpoint && exit 0 || { service autofs stop ; ln -s /localFS /NFS_mountpoint ; }
if [[ $(timeout 5 ls /NFS_mountpoint >/dev/null 2>&1)$? -eq 0 ]]; then
    mail -s "The NFS has failed over to local FS" YourEmail@email.com
    mail -s "Problem on $(hostname)" YourEmail@email.com

This could run as a cronjob every minute ( * * * * *). You would probably have to rename or remove the NFS mountpoint before you can symlink to it, so you might want to change it to mv /NFS_mountpoint /NFS_mountpoint.OLD && ln -s /localFS /NFS_mountpoint

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.