lost and found ( for me ? )

install virtualbox, vagrant on Ubuntu 14.04

Reference
https://docs.vagrantup.com/v2/

1. install virtualbox and vagrant over apt-get.

# apt-get install virtualbox

# apt-get install vagrant

# /etc/init.d/virtualbox status
VirtualBox kernel modules are loaded.

# lsmod | grep vbox
vboxpci                23194  0
vboxnetadp             25670  0
vboxnetflt             27613  0
vboxdrv               339502  3 vboxnetadp,vboxnetflt,vboxpci


# virtualbox --help
Oracle VM VirtualBox Manager 4.3.10_Ubuntu



# dpkg-query -L virtualbox
/.
/etc
/etc/default
/etc/default/virtualbox
/etc/init.d
/etc/init.d/virtualbox
/lib
/lib/udev
/lib/udev/rules.d
/lib/udev/rules.d/40-virtualbox.rules
/lib/udev/VBoxCreateUSBNode.sh

2.  add a box image

# vagrant box add centos7-64 https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box
Downloading box from URL: https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box
Extracting box...te: 3288k/s, Estimated time remaining: --:--:--)
Successfully added box 'centos7-64' with provider 'virtualbox'!



list a box

# vagrant box list
centos7-64 (virtualbox)


# vagrant box list -i
centos7-64 (virtualbox)
 - url: https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box
 - downloaded_at: 2015-05-27 17:07:02 UTC

3.  set up a project

make a directory for the project and initialize an environment.
# mkdir vagrant_project01

# cd vagrant_project01/


root@ubuntu:~/vagrant_project01# vagrant init
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.


root@ubuntu:~/vagrant_project01# grep -v '#' Vagrantfile | grep -v ^$
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
 config.vm.box = "base"
end

edit Vagrantfile to use the box ( CentOS7 ) which I added.
# grep -v '#' Vagrantfile | grep -v ^$
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
 config.vm.box = "centos7-64"
end


4. start the VM and connect to that over SSH


start the VM
root@ubuntu:~/vagrant_project01# vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'centos7-64'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Mounting shared folders...
[default] -- /vagrant



# ps aux | grep virtualbox | grep -v grep
root     12770  0.7  0.0 192456  6172 ?        S    02:23   0:01 /usr/lib/virtualbox/VBoxXPCOMIPCD
root     12776  6.7  0.1 652716 11888 ?        Sl   02:23   0:09 /usr/lib/virtualbox/VBoxSVC --auto-shutdown
root     13240 12.1  0.9 1482056 73448 ?       Sl   02:24   0:15 /usr/lib/virtualbox/VBoxHeadless --comment vagrant_project01_default_1432747444617_66875 --startvm 3ecc3d2d-7fd8-4811-9565-40f23bf32e56 --vrde config

connect to the VM.
# vagrant ssh
Welcome to your Vagrant-built virtual machine.
[vagrant@localhost ~]$ cat /etc/centos-release
CentOS Linux release 7.1.1503 (Core)
[vagrant@localhost ~]$


shutdown the VM.
# vagrant halt
[default] Attempting graceful shutdown of VM...

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.