如何在MacOS上自动挂载NFS共享

4
我希望您在我的Mac启动时自动挂载Synology NAS上的一些NFS共享。 直到最近,这个功能都是正常工作的:
/etc/auto_master:

+auto_master        # Use directory service
/net                -hosts      -nobrowse,hidefromfinder,nosuid
/home               auto_home   -nobrowse,hidefromfinder
/Network/Servers    -fstab
/-                  -static
/-                  auto_nfs    -nobrowse,nosuid


/etc/auto_nfs:

/mnt/idefix/digikam -fstype=nfs,noowners,nolockd,resvport,hard,bg,intr,rw,tcp,nfc,rsize=8192,wsize=8192 nfs://idefix:/volume1/digikam

现在,升级到MacOS 10.15(Catalina)后,这不再起作用了。我做错了什么?


也许尝试添加特定版本的NFS协议,例如intr,rw,tcp,vers = 3或2或4。只是猜测。 - Mark Setchell
尝试了 vers=2、3和4,但没有任何区别... - willemx
哦,好吧,这个尝试还是值得的。也许可以尝试使用 showmount -e idefix 命令来查看它正在导出什么。另外,我不确定你在那里使用的 nfs:// 是否正确。毕竟,它已经默认使用了 NFS 协议,所以可能不需要加上这个前缀。我并不确定这一点,只是猜测一些想法,因为你似乎卡住了! - Mark Setchell
1
我投票关闭此问题,因为它可能属于Ask Different Stack Exchange网站,并且在那里很可能会得到更好的答案。 - Mark Setchell
@willemx 这个问题有任何更新吗? - tefozi
3个回答

6

这不是一个直接的答案,但在我的情况下,我需要更新/etc/auto_nfs中指定的挂载点,从/Users/foo/mountpoint更新到/System/Volumes/Data/Users/foo/mountpoint。Catalina磁盘结构已经改变了目录,也许与你的问题有关。


你还想创建/etc/synthetic.conf,以便下次重启Mac时创建挂载点。它应该包含类似于mnt /System/Volumes/Data/mnt的内容。 - Nick Sillito
已经在/etc/auto_nfs中将路径从/Volumes/Pictures -fstype=nfs,noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.0.155/nfs/Pictures更新为/System/Volumes/Data/Pictures -fstype=nfs,noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc nfs://192.168.0.155/nfs/Pictures,并且问题已得到解决。现在我的图片可以通过此路径/System/Volumes/Data/Pictures找到,这很好。 - tefozi

3

在升级到Catalina(10.15.2)的小更新中,又有一个重大变化。对我起作用的配置如下:

/etc/auto_master:

#
# Automounter master map
#
+auto_master        # Use directory service
#/net           -hosts      -nobrowse,hidefromfinder,nosuid
/home           auto_home   -nobrowse,hidefromfinder
/Network/Servers    -fstab
/-          -static
/Users/Share        auto_nfs


/etc/auto_nfs:

mntp    -noowners,nolockd,noresvport,hard,bg,intr,rw,tcp,nfc server:/share

这将自动挂载共享文件夹 server:/share 到目录 /Users/Share/mntp

1
除了这两个配置文件,您能列举出所有涉及的步骤吗?在创建这两个文件之后,例如,您是否作为普通用户或使用sudo启动mount /Users/Shared/mntp,或者采取其他任何步骤?您是否需要首先运行mkdir /Users/Shared/mtp - ylluminate
1
一旦您更改了auto_master文件,请运行sudo automount -vc。但是,每次MacOS的小/大更新现在都会重置/etc/auto_master,因此必须手动添加/Users/Share...行。我还没有找到一个简单的自动执行此操作的方法(欢迎提供建议!)。 - DanT
嗯,它能工作,但奇怪的是,目录权限只显示为只读/执行(尽管你的命令明确将共享挂载为读/写)。我需要查看我的设置出了什么问题... - undefined

0

以下文章可能对此主题有价值: https://tisgoud.nl/2020/10/persistent-nfs-mount-points-on-macos

在 shell 中查看 man fstab 以获取详细信息。

一个 fstab 行的不同字段:

  • 第 1 个字段:fs_spec,远程文件系统
  • 第 2 个字段:fs_file,文件系统的挂载点
  • 第 3 个字段:fs_vfstype,文件系统的类型
  • 第 4 个字段:fs_mntops,以逗号分隔的挂载选项列表

作者概述的步骤是:

  1. 通过 sudo vifs 编辑 /etc/fstab
  2. 插入所需的字段,作者包括以下示例:
$ cat /etc/fstab
#
# Warning - this file should only be modified with vifs(8)
#
# Failure to do so is unsupported and may be destructive.
#
192.168.200.200:/volume1/calibre /System/Volumes/Data/Nandi/calibre nfs rw,nolockd,resvport,hard,bg,intr,rw,tcp,nfc,rsize=65536,wsize=65536
192.168.200.200:/volume1/docker /System/Volumes/Data/Nandi/docker nfs rw,nolockd,resvport,hard,bg,intr,rw,tcp,nfc,rsize=65536,wsize=65536
192.168.200.200:/volume1/web /System/Volumes/Data/Nandi/web nfs rw,nolockd,resvport,hard,bg,intr,rw,tcp,nfc,rsize=65536,wsize=65536
  1. 通过sudo automount -cv触发挂载点
  2. 检查挂载点,例如:
$ mount
...
map -static on /System/Volumes/Data/Nandi/web (autofs, automounted, nobrowse)
map -static on /System/Volumes/Data/Nandi/docker (autofs, automounted, nobrowse)
map -static on /System/Volumes/Data/Nandi/calibre (autofs, automounted, nobrowse)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接