AMD vs Autofs

As of FreeBSD 10.1, the old BSD amd tool is supposed to be replaced with a new port of autofs. I haven’t moved to autofs yet and still use amd because autofs doesn’t support “multiple mounts”, which are absolutely needed for FreeBSD’s ZFS’s NFS shares to be useful. amd has no problem with this.

Enabling AMD with an additional read-only path

By default, amd looks for NFS servers in /host. I like to have this in /net, and additionally a strictly read-only mount in /netro:

Add the following in /etc/rc.conf:

# Disable autofs
# Enable amd
# Enable additional /net and /netro maps
amd_flags="-a /.amd_mnt -l syslog /host /etc/ /net /etc/ /netro /etc/"

Note that the above references /etc/, which doesn’t exist. We want it to be a copy of /etc/, except with a different path within the AMD “temporary directory” (/.amd_mnt) and with the “ro” mount option added rather than “rw”.

For example, if /etc/ looks like:

/defaults       type:=host;fs:=${autodir}/${rhost}/host;rhost:=${key}
*               opts:=rw,grpid,resvport,vers=3,proto=tcp,nosuid,nodev

…then we want to create a /etc/ which looks like:

/defaults       type:=host;fs:=${autodir}/${rhost}/host-readonly;rhost:=${key}
*               opts:=ro,grpid,resvport,vers=3,proto=tcp,nosuid,nodev