vagrant VirtualBox centos/7 无法共享

2017-12-15  本文已影响403人  custa

现象:

环境:

使用 vagrant 启动 Virtualbox centos/7 box,能够将宿主机当前目录下的文件同步(复制)到虚拟机 /vagrant 目录,但在虚拟机中对 /vagrant 所做的修改并不会在宿主机目录生效,无法实现双向共享

==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Rsyncing folder: /cygdrive/d/VM/centos/ => /vagrant

分析:

从上面启动过程 No guest additions were detected on the base box for this VM! 可以看出 centos/7 缺少 Virtualbox Guest Additions

解决:

vagrant 安装 vagrant-vbguest 插件,在 Vagrantfile 中配置 synced_folder

vagrant plugin install vagrant-vbguest
Vagrant.configure("2") do |config|
  config.vm.synced_folder ".", "/share"
end
==> default: Machine booted and ready!
==> default: Configuring proxy environment variables...
==> default: Configuring proxy for Yum...
[default] No installation found.
Loaded plugins: fastestmirror
...
Installing Virtualbox Guest Additions 5.1.30 - guest version is unknown
...
==> default: Checking for guest additions in VM...
==> default: Rsyncing folder: /cygdrive/d/VM/centos/ => /vagrant
==> default: Mounting shared folders...
    default: /share => D:/VM/centos
上一篇 下一篇

猜你喜欢

热点阅读