Autofs Issues over Ssh Tunnel

I currently use Fedora, and in an effort to come around to trying to use ubuntu, i have hit the following issue. in my environment i use NFS over SSH via an autossh tunnel, to mount a shared tools directory across the whole environment ... On fedora this work fine. On ubuntu, not so much.

yes, from the command line - using the mount commad i can do the mount successfully, through the tunnel

Putting automount into debug mode (automount -f -v -d) the difference appreas to be that fedora tries to bind the mount (as it looks local as it is being served over the ssh tunnel, and when that fails it does a "normal" nfs mount ... as seen here

attempting to mount entry /opt/mynfsmount
lookup_mount: lookup(file): looking up /opt/mynfsmount
lookup_mount: lookup(file): /opt/mynfsmount -> -rw,soft,intr,rsize=8192,wsize=8192,suid,port=9999 localhost:/var/nfs/mynfsmount
parse_mount: parse(sun): expanded entry: -rw,soft,intr,rsize=8192,wsize=8192,suid,port=9999 localhost:/var/nfs/mynfsmount
parse_mount: parse(sun): gathered options: rw,soft,intr,rsize=8192,wsize=8192,suid,port=9999
parse_mount: parse(sun): dequote("localhost:/var/nfs/mynfsmount") -> localhost:/var/nfs/mynfsmount
parse_mount: parse(sun): core of entry: options=rw,soft,intr,rsize=8192,wsize=8192,suid,port=9999, loc=localhost:/var/nfs/mynfsmount
sun_mount: parse(sun): mounting root /opt/mynfsmount, mountpoint /opt/mynfsmount, what localhost:/var/nfs/mynfsmount, fstype nfs, options rw,soft,intr,rsize=8192,wsize=8192,suid,port=9999
mount(nfs): root=/opt/mynfsmount name=/opt/mynfsmount what=localhost:/var/nfs/mynfsmount, fstype=nfs, options=rw,soft,intr,rsize=8192,wsize=8192,suid,port=9999
mount(nfs): nfs options="rw,soft,intr,rsize=8192,wsize=8192,suid,port=9999", nobind=0, nosymlink=0, ro=0
mount_mount: mount(nfs): calling mkdir_path /opt/mynfsmount
mount_mount: mount(nfs): /opt/mynfsmount is local, attempt bind mount
mount_mount: mount(bind): calling mkdir_path /opt/mynfsmount
mount(bind): calling mount --bind -o defaults /var/nfs/mynfsmount /opt/mynfsmount
>> mount: /opt/mynfsmount: special device /var/nfs/mynfsmount does not exist.
mount(nfs): calling mount -t nfs -s -o rw,soft,intr,rsize=8192,wsize=8192,suid,port=9999 localhost:/var/nfs/mynfsmount /opt/mynfsmount
mount_mount: mount(nfs): mounted localhost:/var/nfs/mynfsmount on /opt/mynfsmount
dev_ioctl_send_ready: token = 13
mounted /opt/mynfsmount

the interesting bit being here ... where the bind mount fails and it does the "normal" mount ...

mount(bind): calling mount --bind -o defaults /var/nfs/mynfsmount /opt/mynfsmount
>> mount: /opt/mynfsmount: special device /var/nfs/mynfsmount does not exist.
mount(nfs): calling mount -t nfs -s -o rw,soft,intr,rsize=8192,wsize=8192,suid,port=9999 localhost:/var/nfs/mynfsmount /opt/mynfsmount

on ubuntu ...

attempting to mount entry /opt/mynfsmount
lookup_mount: lookup(file): looking up /opt/mynfsmount
lookup_mount: lookup(file): /opt/mynfsmount -> -rw,ver=4.2,soft,intr,rsize=8192,wsize=8192,suid,port=9999 localhost:/var/nfs/mynfsmount
parse_mount: parse(sun): expanded entry: -rw,ver=4.2,soft,intr,rsize=8192,wsize=8192,suid,port=9999 localhost:/var/nfs/mynfsmount
parse_mount: parse(sun): gathered options: rw,ver=4.2,soft,intr,rsize=8192,wsize=8192,suid,port=9999
parse_mount: parse(sun): dequote("localhost:/var/nfs/mynfsmount") -> localhost:/var/nfs/mynfsmount
parse_mount: parse(sun): core of entry: options=rw,ver=4.2,soft,intr,rsize=8192,wsize=8192,suid,port=9999, loc=localhost:/var/nfs/mynfsmount
sun_mount: parse(sun): mounting root /opt/mynfsmount, mountpoint /opt/mynfsmount, what localhost:/var/nfs/mynfsmount, fstype nfs, options rw,ver=4.2,soft,intr,rsize=8192,wsize=8192,suid,port=9999
mount_mount: mount(nfs): root=/opt/mynfsmount name=/opt/mynfsmount what=localhost:/var/nfs/mynfsmount, fstype=nfs, options=rw,ver=4.2,soft,intr,rsize=8192,wsize=8192,suid,port=9999
mount_mount: mount(nfs): nfs options="rw,ver=4.2,soft,intr,rsize=8192,wsize=8192,suid,port=9999", nobind=0, nosymlink=0, ro=0
mount_mount: mount(nfs): calling mkdir_path /opt/mynfsmount
mount_mount: mount(nfs): /opt/mynfsmount is local, attempt bind mount
mount_mount: mount(bind): calling mkdir_path /opt/mynfsmount
mount_mount: mount(bind): calling mount --bind -o defaults /var/nfs/mynfsmount /opt/mynfsmount
>> mount: /opt/mynfsmount: special device /var/nfs/mynfsmount does not exist.
mount(nfs): nfs: mount failure localhost:/var/nfs/mynfsmount on /opt/mynfsmount
dev_ioctl_send_fail: token = 31
failed to mount /opt/mynfsmount

with the failure here, but no try of the normal mount

  mount_mount: mount(bind): calling mount --bind -o defaults /var/nfs/mynfsmount /opt/mynfsmount
    >> mount: /opt/mynfsmount: special device /var/nfs/mynfsmount does not exist.
    mount(nfs): nfs: mount failure localhost:/var/nfs/mynfsmount on /opt/mynfsmount
    dev_ioctl_send_fail: token = 31
    failed to mount /opt/mynfsmount

i have looked at the config options, but cannot see any that seem to simply imply this behaviour, any help would be greatly appreciated.

Ubuntu -

Starting automounter version 5.1.5, master map /etc/auto.master

root@ubuntu:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 19.10
Release:        19.10
Codename:       eoan

Fedora -

Starting automounter version 5.1.6-1.fc31, master map auto.master

cat /etc/redhat-release 
Fedora release 31 (Thirty One)

thanks in advance ... c

0

1 Answer

I found out how to do it, i didn't check the man pages well enough

man 5 auto.master

      nobind This is an autofs specific option that is a pseudo mount option and so is given without a leading dash. It may be used either in the master map entry (so it effects all  the  map  entries)  or
             with  individual  map entries to prevent bind mounting of local NFS filesystems. For direct mount maps the option is only effective if specified on the first direct map entry and is applied to
             all direct mount maps in the master map. It is ignored if given on subsequent direct map entries. It may be used on individual map entries of both types. Preventing bind  mounts  of  NFS  file
             systems can no longer be done by using the "port=" option, the nobind option must be used instead.

so the revised, working command line in /etc/auto.direct looks like this:

/opt/mynfsmount  -rw,soft,intr,rsize=8192,wsize=8192,suid,port=9999,nobind,fstype=nfs4 localhost:/var/nfs/mynfsmount

the fstype=4 isn't required (but added in my testing), but the nobind is definitely required, and now it works.

hope this helps someone else!

c

Your Answer

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

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest