Nfs – OpenBSD configuration: Client unable to mount via NFS using Berkeley Automounter (amd)

automountnfsopenbsd

What I am trying to do is to have my openBSD client (OpenBSD 4.9) auto mount a Linux NFS file system (Scientific Linux 6.1). So far, I am not sure if it is configured correctly.

To get things out of the way, I am able to mount nfs manually:

# mount_nfs -T -3 192.168.15.100:/exports /mnt
# ls -la /mnt
total 52
drwxr-xr-x   7 root    wheel   4096 Oct  4 22:42 .
drwxr-xr-x  16 root    wheel    512 Nov 26 16:33 ..
drwxrwxr-x   5 _sndio  _sndio  4096 Oct 31 21:58 centos
drwxr-xr-x  15 root    wheel   4096 Nov  6 09:17 home
drwxr-xr-x   5 root    wheel   4096 Oct 31 21:27 sl
drwxr-xr-x   3 root    wheel   4096 Nov 19 16:02 sles
drwxr-xr-x  17 503     503     4096 Nov 10 17:37 users
# 

So connectivity is not an issue, as far as I can tell.

As per man page, the following is configured in /etc/amd/auto.home:

/defaults type:=nfs;sublink:=${key};opts:=rw,soft,intr,vers=3,proto=tcp
*         rhost:=192.168.15.100;rfs:=/exports

In turn, /etc/amd/master is configured as such:

# cat /etc/amd/master                                                                                                                                                                    
/exports amd.home

Upon reboot, I can it see mount, but curiously enough, instead of the hostname:

amd:24490                        0         0         0   100%    /exports

From what I understand, amd acts a little different from FreeBSD. Still, I tried to see if I it can automount.

Nope:

ksh: cd: /exports/users - Resource temporarily unavailable
# cd /exports/192.168.15.100/host/users
ksh: cd: /exports/192.168.15.100/host/users - Resource temporarily unavailable

A search in google doesn't help too much – it seems that automounting NFS with OpenBSD is not something that is usually done. Other than this, information is fairly sparse.

I can, of course, always mount is permanently, but I tend to be a bit anal on convention, so no for now. 🙂

Some direction would be appreciation.

(And oh, in case you are a wondering, I tried FreeBSD way of using amd and that hasn't worked out – although I wouldn't mind an explanation of the difference between how FreeBSD implements and how OpenBSD implements it)

UPDATE: After re-writing the map file several times, I got as far as actually communicating with the NFS server with this configuration:

/defaults type:=nfs;rhost:=kerberos.monzell.com;rfs:=/exports;\
          sublink:=${key};opts:=rw,nodev,nosuid,soft,intr,tcp,resvport
*         ${host}==${rhost};type:=nfs;fs:=${rfs};opts:=rw,nodev,nosuid,soft,intr,tcp,resvport

However, for some reason, it seems that amd will only default to NFS version 2 over udp:

# tcpdump dst kerberos
tcpdump: listening on pcn0, link-type EN10MB
tcpdump: WARNING: compensating for unaligned libpcap packets
20:38:28.558385 openbsd.monzell.com.856 > kerberos.monzell.com.sunrpc: udp 100
20:38:28.559154 openbsd.monzell.com.856 > kerberos.monzell.com.892: udp 96
20:38:30.592761 openbsd.monzell.com.856 > kerberos.monzell.com.nfsd: xid 0x22000000 (NFSv2) 40 null
20:38:33.558107 arp reply openbsd.monzell.com is-at 52:54:00:52:8f:66

I tried various options of forcing it to try to mount as nfsv3 such as:

/defaults type:=nfs;rhost:=kerberos.monzell.com;rfs:=/exports;\
          sublink:=${key};opts:=rw,nodev,nosuid,soft,intr,vers=3,proto=tcp,resvport
*         ${host}==${rhost};type:=nfs;fs:=${rfs};opts:=rw,nodev,nosuid,soft,intr,vers=3,proto=tcp,resvport

or:

/defaults type:=nfs;rhost:=kerberos.monzell.com;rfs:=/exports;\
          sublink:=${key};opts:=rw,nodev,nosuid,soft,intr,vers=-3,proto=tcp,resvport
*         ${host}==${rhost};type:=nfs;fs:=${rfs};opts:=rw,nodev,nosuid,soft,intr,vers=3,proto=tcp,resvport

Nothing yet still.

Curious enough, OpenBSD mounts defaults to version 3, so I am not sure why it would start with version 3 in amd. What would be the correct options to pass to automount?

EDIT: As I pointed out, I can point via fstab. For proof, here it is:

kerberos:/exports /mnt nfs rw,nodev,nosuid,tcp,soft,intr 1 1 
Filesystem        512-blocks      Used     Avail Capacity  Mounted on
/dev/wd0a             290396     89032    186848    32%    /
/dev/wd0k            3240316   1858940   1219364    60%    /home
/dev/wd0d             448956        12    426500     0%    /tmp
/dev/wd0f            1943196    903596    942444    49%    /usr
/dev/wd0g            1105820    346852    703680    33%    /usr/X11R6
/dev/wd0h            4387772    256560   3911824     6%    /usr/local
/dev/wd0j            2137436         4   2030564     0%    /usr/obj
/dev/wd0i            2137436         4   2030564     0%    /usr/src
/dev/wd0e             498940     18676    455320     4%    /var
amd:26660                  0         0         0   100%    /net
kerberos:/exports  103212280  66319088  31650312    68%    /mnt

As I noted, OpenBSD mounts via version 3 first, so I don't know why under amd, it would not mount via version 3 (tcp) and instead mount via version 2 with udp.

EDIT: As suggested, I attempted the following configurations:

defaults type:=nfs;fs:=${autodir}
  # autodir = -a parameter of amd call = amd_mnt in rc.conf = /tmp_mnt
  # Be careful with 'umount' and 'unmount' in the following.
remote type:=program;fs:=/mnt;\
        mount:="/sbin/mount_nfs kerberos.monzell.com:/exports/";\
        unmount:="/sbin/umount /mnt"

That returned

# cd /net/remote                                                                                                                                                                                 
usage:  [-23bcdilsTU] [-a maxreadahead] [-g maxgroups]
        [-I readdirsize] [-o options] [-R retrycnt] [-r readsize]
        [-t timeout] [-w writesize] [-x retrans] rhost:path node
ksh: cd: /net/remote - Operation not permitted

Then this:

defaults type:=nfs;fs:=${autodir}
  # autodir = -a parameter of amd call = amd_mnt in rc.conf = /tmp_mnt
  # Be careful with 'umount' and 'unmount' in the following.
remote type:=program;fs:=/mnt;\
        mount:="/sbin/mount nfs kerberos.monzell.com:/exports/";\
        unmount:="/sbin/umount /mnt"

Which returned this:

# cd /net/remote                                                                                                                                                                                 
nfs: realpath kerberos.monzell.com:/exports/: No such file or directory
ksh: cd: /net/remote - Operation not permitted

Nothing yet.

Best Answer

Finally "figured" it out. What I did is to copy an existing FreeBSD map file to /etc/amd/amd.net as follows:

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

{autodir} is set to the default directory used by amd (which is apparently /tmp_mnt, while ${rhost} is the remote host as specified by the key (which looks for the host name either in DNS or in /etc/hosts file:

192.168.15.250          qnap    qnap.monzell.com

On top of that is the host directory.

Then I created a directory in the root as:

/etc/amd/master:

/host amd.net

Then I create a host directory under root. Afterwards, it works as expected.

$ df
Filesystem   512-blocks      Used     Avail Capacity  Mounted on
/dev/wd0a        290396     89088    186792    32%    /
/dev/wd0k       3240316   1858968   1219336    60%    /home
/dev/wd0d        448956        12    426500     0%    /tmp
/dev/wd0f       1943196    903596    942444    49%    /usr
/dev/wd0g       1105820    346852    703680    33%    /usr/X11R6
/dev/wd0h       4387772    256560   3911824     6%    /usr/local
/dev/wd0j       2137436         4   2030564     0%    /usr/obj
/dev/wd0i       2137436         4   2030564     0%    /usr/src
/dev/wd0e        498940     18656    455340     4%    /var
amd:9747              0         0         0   100%    /host
qnap:/Public 1916713232 642213152 1274500080    34%    /tmp_mnt/qnap/host/Public
qnap:/pub    1916713232 642213152 1274500080    34%    /tmp_mnt/qnap/host/pub
qnap:/users  1916713232 642213152 1274500080    34%    /tmp_mnt/qnap/host/users

It looks like most communication NFS needs to be through the host, which takes care of the remote mount via NFSv3/TCP. Any attempts to mount remotely via amd directly will default to udp,version 2.

Still don't really understand amd, but I got it working, which means I am mostly there. :)