美文网首页
vagrant VirtualBox centos/7 无法共享

vagrant VirtualBox centos/7 无法共享

作者: custa | 来源:发表于2017-12-15 14:38 被阅读403次

    现象:

    环境:
    • Windows 10
    • VirtualBox 5.1.30
    • Vagrant 1.9.8
    • centos/7 box

    使用 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-vbguest
    vagrant plugin install vagrant-vbguest
    
    • Vagrantfile 配置共享目录,挂载位置不能使用 /vagrant
    Vagrant.configure("2") do |config|
      config.vm.synced_folder ".", "/share"
    end
    
    • 启动过程会自动安装 Virtualbox Guest Additions,启动后配置的共享目录可以双向读写
    ==> 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
    

    相关文章

      网友评论

          本文标题:vagrant VirtualBox centos/7 无法共享

          本文链接:https://www.haomeiwen.com/subject/gugrwxtx.html