zoukankan      html  css  js  c++  java
  • vagrant 多个box的操作|共享目录失败

    本来机器上已经有一个Ubuntu的box了,今天想在安装一个centos的box,结果还折腾了很长时间。

    多个机器的命令

    添加box的时候需要使用名称,一个的时候可以忽略名称

    vagrant box add Ubuntu.box
    多个的时候必须指定名称
    vagrant box add centos CentOS-7-x86_64-Vagrant-1910_01.VirtualBox.box
    

    init也一样,需要指定刚刚创建的名字

    vagrant init centos
    

    然后执行 up,竟然报错了

    vagrant up centos
    The machine with the name 'centos' was not found configured for
    this Vagrant environment.
    

    竟然没有发现 centos vagrant 环境。奇怪的事,明明是有的。后来查了下资料,需要做个名称定义

    config.vm.define "centos"
    

    看下我的 Vagrantfile 的完整内容

    Vagrant.configure("2") do |config|
      config.vm.define "centos"
      config.vm.box = "centos"
      config.vm.box_url = "CentOS-7-x86_64-Vagrant-1910_01.VirtualBox.box"
    end
    

    然后按需执行

    vagrant up centos
    vagrant ssh centos
    

    终于起来登录了。

    无法共享目录

    起来之后又有新新的问题了,无法共享目录。

    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 home_vagrant /home/vagrant/
    
    The error output from the command was:
    
    /sbin/mount.vboxsf: mounting failed with the error: No such device
    

    查了下资料,说是扩展的问题。执行下以下命令更新扩展就可以了, https://github.com/scotch-io/scotch-box/issues/296

    vagrant plugin install vagrant-vbguest
    vagrant vbguest
    

    更新比较忙,还可能被墙。
    更新完之后直接 reload就能看到共享目录了。

  • 相关阅读:
    正则表达式验证银行卡号
    正则表达式验证银行卡号
    正则表达式验证手机号
    正则表达式验证手机号
    好用的手机浏览器
    jmeter(三)跨线程组调用token
    jmeter(二)ant报告模板下载与使用
    1-5JSON数据解析
    1-3HTTP协议基础
    1-2接口测试概述
  • 原文地址:https://www.cnblogs.com/feixiangmanon/p/12907097.html
Copyright © 2011-2022 走看看