vagrant常见问题总结

Posted 黑暗森林

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vagrant常见问题总结相关的知识,希望对你有一定的参考价值。

记录vagrant使用过程中遇到的问题,会持续补充

  • 升级virtualbox后,出现挂载host目录问题

环境

host win10
virtualbox 6.1.22
vm centos 7

问题现象:
之前vm设置过与host的文件共享,Vagrantfile中配置

config.vm.synced_folder "D:/work/vagrant/data", "/vagrant_data"

virtualbox从6.1.16升级到6.1.22, 升级后vagrant up显示如下问题

==> pg12: Checking for guest additions in VM...
==> pg12: Setting hostname...
==> pg12: Configuring and enabling network interfaces...
==> pg12: Mounting shared folders...
    pg12: /vagrant => D:/work/vagrant/vms/pg12
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:

/sbin/mount.vboxsf: mounting failed with the error: Invalid argument

解决方法:
ssh登陆vm,将vagrant(vagrant为vm默认登陆用户,根据实际情况配置)添加到vboxsf,vboxusers 组

sudo groupadd vboxusers
usermod -G vboxusers vagrant
usermod -G vboxsf vagrant

vm关机,再vagrant up启动后即可

[vagrant@pg12 ~]$ groups
vagrant vboxusers

检查共享目录挂载成功

[vagrant@pg12 ~]$ ls /vagrant_data/
a b c.sh
  • TBD

以上是关于vagrant常见问题总结的主要内容,如果未能解决你的问题,请参考以下文章

BootStrap有用代码片段(持续总结)

BootStrap实用代码片段(持续总结)

python常用代码片段总结

回归 | js实用代码片段的封装与总结(持续更新中...)

查看发票组代码后的总结和有感

Vagrant 搞砸了代码?