关于vagrant: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

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理