vagant+virtualBox 安装linux系统
1.新建一个目录作为 Vagrant 的工程目录
$haohao cd /Users/haohao
$haohao mkdir vagrant
2.添加前面下载的 box
添加 box 命令格式:vagrant box add <本地 box 名称> <box 文件>
本地 box 名称:自定义名称,该名称是本地 vagrant 管理时使用的名称;
box 文件:前面下载的 vagrant box 文件或者远程 box url 地址;
$haohao vagrant box add ubuntu-server-16.04 ubuntu-server-16.04-amd64-vagrant.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'ubuntu-server-16.04' (v0) for provider:
box: Unpacking necessary files from: file:///Users/haohao/vagrant/ubuntu-server-16.04-amd64-vagrant.box
==> box: Successfully added box 'ubuntu-server-16.04' (v0) for 'virtualbox'!
3.查看 box 是否添加成功
查看当前 vagrant 中有哪些 box:vagrant box list
$haohao vagrant box list
ubuntu-server-16.04 (virtualbox, 0)
4.初始化上面添加的 box
初始化命令格式:vagrant init <本地 box 名称>
本地 box 名称:第 2 步中添加的 box 名称
这里初始化前面添加的 box,初始化后会在当前目录生产一个 Vagrantfile 文件,里面包含了虚拟机的各种配置,关于具体每个配置项是什么意思,后面会介绍。
$haohao vagrant init 'ubuntu-server-16.04'
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
5.启动虚拟机
虚拟机启动命令:vagrant up
启动虚拟机时会自动将当前目录(即 Vagrantfile 文件所在目录),和虚拟机的 /vagrant 目录共享。
$haohao vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu-server-16.04'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: vagrant_default_1524288099752_62326
==> default: Clearing any previously set network interfaces...
.....
==> default: Mounting shared folders...
default: /vagrant => /Users/haohao/vagrant
6.连接虚拟机
命令格式:vagrant ssh
$haohao vagrant ssh
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-98-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
0 packages can be updated.
0 updates are security updates.
http://www.vagrantbox.es/ vagrantbox url 下载
原文:https://blog.csdn.net/qianghaohao/article/details/80038096
版权声明:本文为博主原创文章,转载请附上博文链接!我们尊重作者