关于vagrant:vagrant常见问题总结

4次阅读

共计 1140 个字符,预计需要花费 3 分钟才能阅读完成。

记录 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
正文完
 0