将NFS与vagrant一​​起使用并不起作用

时间:2014-11-23 12:44:51

标签: vagrant nfs vagrantfile

我的Vagrantfile中有以下内容:

config.vm.network :private_network, ip: "10.0.0.103"
config.vm.synced_folder ".", "/vagrant/", type: "nfs"

在新盒子上执行vagrant up会产生:

==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o 'vers=3,udp' 10.0.0.1:'/Users/wayne/app' /vagrant

Stdout from the command:



Stderr from the command:

stdin: is not a tty
mount.nfs: access denied by server while mounting 10.0.0.1:/Users/wayne/app

然后我需要vagrant reload它似乎有用......但我当然不应该这样做吗?

[更新:日志输出]

INFO retryable: Retryable exception raised: #<Vagrant::Errors::LinuxNFSMountFailed: The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o 'vers=3,udp' 10.0.0.1:'/Users/wayne/sonatribe' /vagrant

Stdout from the command:



Stderr from the command:

stdin: is not a tty
mount.nfs: requested NFS version or transport protocol is not supported
>
 INFO ssh: Execute: mount -o 'vers=3,udp' 10.0.0.1:'/Users/wayne/sonatribe' /vagrant (sudo=true)
 INFO retryable: Retryable exception raised: #<Vagrant::Errors::LinuxNFSMountFailed: The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o 'vers=3,udp' 10.0.0.1:'/Users/wayne/sonatribe' /vagrant

Stdout from the command:



Stderr from the command:

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

6 个答案:

答案 0 :(得分:5)

对于Linux,我在主机上执行此操作:

systemctl stop nfs-kernel-server.service
systemctl disable nfs-kernel-server.service
systemctl enable nfs-kernel-server.service
systemctl start nfs-kernel-server.service

答案 1 :(得分:2)

由于主机VirtualBox和Guest Additions版本不匹配,可能会发生这种情况。在这种情况下,就在启动日志中的错误行之前,您应该得到:

  ==> default: Checking for guest additions in VM...
  default: The guest additions on this VM do not match the installed version of
  default: VirtualBox! In most cases this is fine, but in rare cases it can
  default: prevent things such as shared folders from working properly. If you see
  default: shared folder errors, please make sure the guest additions within the
  default: virtual machine match the version of VirtualBox you have installed on
  default: your host and reload your VM.
  default:
  default: Guest Additions Version: 5.0.26
  default: VirtualBox Version: 5.1

在我的情况下,将VirtualBox更新到最新版本修复了问题。

或者,您可以确保使用主机上的vbguest Vagrant插件安装了正确的Guest Addition版本:

vagrant plugin install vagrant-vbguest

答案 2 :(得分:1)

降级并将基本映像更改为LTS Ubuntu(而不是XUbuntu)似乎解决了这个问题。

答案 3 :(得分:0)

可能是由于Os补丁和软件包升级所致,我的流浪汉env停止工作了,这使我浪费了大约4个小时的宝贵时间。感谢上帝,这就是我设法解决的方法:我使用ubuntu 18.04,vbox 6。

  1. 使用vagrant plugin install vagrant-vbguest重新安装流浪vbguest插件
  2. 确保vbox来宾添加项与virtualbox匹配。最好安装最新的[下载VBx来宾添加项] [1]
  3. 以某种方式缺少NFS软件包,所以sudo apt-get install -y nfs-server
  4. 重新启动
  5. 以管理员权限运行以下内容
 sudo systemctl disable nfs-kernel-server.service
 sudo systemctl enable nfs-kernel-server.service
 sudo systemctl start nfs-kernel-server.service```

6. just to be sure i did `vagrant destroy` with `vagrant global-status --prune`

[1]: https://www.virtualbox.org/wiki/Downloads

答案 4 :(得分:0)

TL; DR-检查以确保/ etc / exports中的所有条目都指向存在的文件夹。如果您删除或重命名了以前配置为NFS共享的任何文件夹,则可能导致以后所有尝试在主机和客户端VM之间启动NFS共享的尝试失败。

此线程仍然是搜索结果中此错误的最高结果,还有另一个潜在的潜在原因-/ etc / exports中的挂载失败

NFS服务器将读取/ etc / exports以获取其挂载列表,并且如果其中配置的条目不再有效(例如,您移动/重命名/删除了文件夹),将导致nfs服务器无法启动。根据操作系统的不同,命令会有所不同,但是如果检查NFS服务器的状态,可能会发现由于/ etc / exports中的配置问题而导致NFS无法启动。

答案 5 :(得分:0)

here所述,有时会在Linux发行版中未安装nfs-server时发生。 here解释了如何根据您的发行版进行安装。今天对我有用。 o /