autofs supports a -hosts
map, which looks like this:
#
# NOTE: mounts done from a hosts map will be mounted with the
# "nosuid" and "nodev" options unless the "suid" and "dev"
# options are explicitly given.
#
/net -hosts
This apparently invokes /etc/auto.net
which uses (k)showmount to get a list of exported filesystems from the remote machine. Unfortunately, this requires the nfsv3 mountd to be running/available on the remote machine, which you may not have available on a pure nfsv4 setup.
Because of the way nfsv4 works with the pseudo-root filesystem that dynamically exposes the list of available filesystems on a per-client basis, just the root export needs to be exposed. The server enumerates the available filesystems for the client via the pseudo-root, so this just needs to know about, and attempt to mount, targetmachine:/
, not all the paths listed in /etc/exports
on the remote machine as is necessary for nfsv3.
But we only want to attempt to mount it if it looks like nfsv4 is running, otherwise the client program could pause while attempting to connect to an inaccessible machine. A simplistic TCP connect test, with a 1 second time out, is used to see if there is an nfsv4 server on the remote machine.
Inspiration from https://bugzilla.redhat.com/show_bug.cgi?id=643142