Vagrant 无法在 Ubuntu 20 虚拟机中挂载 NFS

问题描述 投票:0回答:2

我使用 vagrant 工作了几年,主要是创建和运行 Ubuntu 16/18 虚拟机 (VM)。最近,我尝试升级到 Ubuntu 20 虚拟机并遇到以下错误:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o vers=3,udp 192.168.121.1:/home-local/some_user/vagrant_demo/tmp /home/vagrant/shared

Stdout from the command:



Stderr from the command:

mount.nfs: requested NFS version or transport protocol is not supported

我的

Vagrantfile
的片段:

Vagrant.configure("2") do |config|
  ...
  config.vm.box = "generic/ubuntu2004"
  ...
  config.vm.synced_folder ".", "/home/vagrant/shared", type: "nfs"
  ...
end

因此,我尝试通过将

nfs_version: 4
添加到我的
Vagrantfile
来指定较新的 NFS 版本,但仍然遇到相同的错误:

mount.nfs: requested NFS version or transport protocol is not supported

我还尝试用

Vagrantfile
修复
nfs_version: 4, nfs_udp: true
但随后又出现了另一个错误:

mount.nfs: an incorrect mount option was specified

更多细节:主机有 Ubuntu 20 LTS 和 Vagrant 2.2.10。 我在这里询问(而不是报告 vagrant github 存储库中的错误),因为它看起来像是 NFS 配置问题。任何帮助将不胜感激!

linux vagrant nfs
2个回答
0
投票

我想我发现了问题:主机和来宾中的Linux内核是v5.10而不是v5.4,这是Ubuntu 20的默认版本。 当我回到内核 v5.4 后,NFS 的问题就消失了。我认为这与内核 v5.6 禁用 NFS 的 UDP 协议支持有关: https://cateee.net/lkddb/web-lkddb/NFS_DISABLE_UDP_SUPPORT.html


0
投票

如果带有 UDP 的 nfs 不起作用,我们会收到该错误。可以通过此选项要求 Vagrant 不要使用 UDP:

nfs_udp: false

所以你可以像这样配置你的synced_folder:

config.vm.synced_folder ".", "/home/vagrant/shared", type: "nfs", nfs_udp: false
© www.soinside.com 2019 - 2024. All rights reserved.