我目前使用 Fedora,在尝试使用 ubuntu 时,我遇到了以下问题。在我的环境中,我通过 autossh 隧道使用 NFS over SSH,在整个环境中挂载共享工具目录... 在 fedora 上,这可以正常工作。在 ubuntu 上,情况就不一样了。
是的,从命令行 - 使用 mount 命令我可以通过隧道成功挂载
将自动挂载置于调试模式(automount -f -v -d),不同之处在于 fedora 尝试绑定挂载(因为它看起来像是本地的,因为它是通过 ssh 隧道提供服务的,当失败时它会执行“正常”的 nfs 挂载...如此处所示
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
有趣的是这里...绑定挂载失败并且它执行“正常”挂载...
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
在 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
这里失败了,但没有尝试正常挂载
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
我已经查看了配置选项,但看不到任何似乎只是暗示这种行为的选项,如能提供任何帮助我将不胜感激。
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)
提前致谢...c
答案1
我找到了如何做到这一点,但我没有仔细查看手册页
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.
因此修改后的、有效的命令行/etc/auto.direct看起来像这样:
/opt/mynfsmount -rw,soft,intr,rsize=8192,wsize=8192,suid,port=9999,nobind,fstype=nfs4 localhost:/var/nfs/mynfsmount
这fstype=4不是必需的(但在我的测试中添加),但不绑定绝对是必要的,而且现在它可以工作了。
希望这对其他人有帮助!
C