Vagrant 无法在 linux 来宾上安装同步文件夹 --:协议错误

Vagrant unable to mount synced folder on linux guest -- :Protocol Error

我在 VirtualBox 中使用 Vagrant 与 Windows 主机和 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 显示同步文件夹名为 vagrant 小写 'v',并且 VirtualBox 显示共享文件夹的名称小写 'v',即使在重新启动盒子.

我真的需要 vagrant 的默认行为才能正常工作而不报错。是什么导致了这种情况?

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

/home/vagrant/vagrant --> /vagrant

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