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
autofs_enable="NO"
# Enable amd
amd_enable="YES"
# Enable additional /net and /netro maps
amd_flags="-a /.amd_mnt -l syslog /host /etc/amd.map /net /etc/amd.map /netro /etc/amd-ro.map"
Note that the above references /etc/amd-ro.map
, which doesn’t exist. We want it to be a copy of /etc/amd.map
, 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/amd.map
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/amd-ro.map
which looks like:
/defaults type:=host;fs:=${autodir}/${rhost}/host-readonly;rhost:=${key}
* opts:=ro,grpid,resvport,vers=3,proto=tcp,nosuid,nodev