到公司打开笔记本,启动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=1001,gid=1001 work_ /work
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: No such file or directory
让我们来翻译下:
vagrant 无法装载VirtualBox的共享文件夹,因为文件系统"vboxsf"无法使用.
这个文件系统通过VirtualBox客户添加内核模块获得,请确认是否被正确安装.
这不是vagrant的问题,而是VirtualBox引起的问题.
请尝试执行,以下命令:
mount -t vboxsf -o uid=1001,gid=1001 work_ /work
命令输出的错误信息为:
sbin/mount.vboxsf:挂载失败:找不到这个文件或目录
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
#config.vm.synced_folder "E:/project/projects/server", "/work/", owner: "www-data", group: "www-data"
#自动同步的目录
config.vm.synced_folder "D:/Project/php/", "/work/", owner: "www-data", group: "www-data"
百思不得其解时,我再次想起了错误现象中的那句, "这不是vagrant的问题,而是VirtualBox引起的问题",或许这几句话是对的呢.
顺着这个思路,我访问了VirtualBox官网的buglist, 找到了这个信息
可以看到,是在5.1.20这个版本中出现的这个问题, 我看了下我使用的版本是5.1.16, 竟然比这个有问题的版本还低.
最下面写到,已在5.1.22修复了这个问题.
那么,立刻升级吧. 下载新版本安装后,重新启动, 果然,问题解决了,请看截图,提示共享目录,挂载成功.