Simplify virtualization using Virtual Box and Vagrant


28 Mar


As stated on https://en.wikipedia.org/wiki/VirtualBox, 

Oracle VM VirtualBox (formerly Sun VirtualBox, Sun xVM VirtualBox and Innotek VirtualBox) is a free and open-sourcehostedhypervisor for x86 computers and is under development by Oracle Corporation. VirtualBox may be installed on a number of host operating systems, including Linux, macOS, Windows, Solaris and OpenSolaris. It supports the creation and management of guest virtual machines running versions and derivations of Windows, Linux, BSD, OS/2, Solaris, Haiku, OSx86 and others, and limited virtualization of macOS guests on Apple hardware.

Vagrant is an open-source software product for building and maintaining portable virtual software development environments, e.g. for VirtualBox, KVM, Hyper-V, Docker containers, VMware, and AWS. It tries to simplify software configuration management of virtualizations in order to increase development productivity.


In our example VirtualBox will be used as a hypervisor, meaning it will provide the base resources for VMs and Vagrant will be used to quickly deploy VMs using a configuration file and a limited number of commands.

Prerequisites

  • Install VirtualBox
  • Install Vagrant

Installing VirtualBox

Go to the VirtualBox download page, choose your operating system and download and install the software.

We used Windows operating system and version 5.2.26.


Installing Vagrant

Go to the Vagrant download page, choose your operating system (Windows or macOS) and download and install the software.

We choose 64-bit Windows as operating system.


Download the VM template

Using the command prompt:

C:\Users\d8\VirtualBox VMs>vagrant box add --name oel73 http://yum.oracle.com/boxes/oraclelinux/ol73/ol73.box

Init Vagrant

C:\Users\d8\VirtualBox VMs>vagrant init oel73
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.

This will create a file named Vagrantfile that contains the configuration for the future VM.

This configuration can be changed to customize VM configuration or even to startup multiple VMs.

Startup VM

C:\Users\d8\VirtualBox VMs>vagrant up

After finishing the command, the new machine(s) will be available in VirtualBox.

Stop VM

C:\Users\d8\VirtualBox VMs>vagrant halt

Connect VM

C:\Users\d8\VirtualBox VMs>vagrant ssh

Destroy VM

C:\Users\d8\VirtualBox VMs>vagrant destroy -f






Comments
* The email will not be published on the website.