Vagrant 无法在 linux 客户机上挂载同步的文件夹 -- :P rotocol 错误



我在使用Vagrant的同步文件夹与Windows主机和在VirtualBox中运行的Linux来宾时遇到了一个奇怪的问题。

在首次启动时(或vagrant destroy后),项目文件夹将装载到/vagrant,没有问题,但在停止并启动 VM 后,该文件夹将不会装载。

这是出现在Vagrant输出末尾的错误消息:

...
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant
The error output from the command was:
: Protocol error

Vagrantfile 中没有与同步文件夹相关的配置选项,我只是尝试使用默认的同步文件夹行为。

一些类似的问题表明,运行安装 Vagrant 插件vagrant-vbguest可能会解决一些类似的问题,但我有这个插件。 此外,Virtual Box 和已安装的来宾添加项都是版本 5.1.10。

计算机重新启动后,运行sudo mount -t vboxsf vagrant /vagrant只会给出此错误:

/sbin/mount.vboxsf: mounting failed with the error: Protocol error

出于某种原因,sudo mount -t vboxsf Vagrant /vagrant(大写 V)将挂载同步的文件夹。 在第一次启动时,mount | grep vagrant显示同步的文件夹以小写的"v"命名为vagrant,而VirtualBox以小写的"v"显示共享文件夹的名称,即使在重新启动该框后也是如此。

我真的需要流浪汉的默认行为才能正常工作而不会出错。 是什么原因导致这种情况发生?

我设法通过删除作为配置过程的一部分创建的符号链接来解决此问题:

/home/vagrant/vagrant --> /vagrant

我不太明白这个符号链接如何导致我遇到的问题,但删除它绝对是解决方案。

最新更新