Try our new open source stack builder and get a free, customized report >> Get Started
Virtualization can be time-consuming, especially in open source. But if you use Vagrant and VirtualBox, you can virtualize and save time. Here's how.
VirtualBox is an open source (GPL v2) virtualization platform that works on almost any base OS.
Your virtual machines will be hosted in this on top of your base OS, sharing its resources. For advanced users, it also has some command line, advanced networking capabilities, and integrates nicely with Vagrant.
Vagrant is a time-saving open source (MIT) tool from our friends at HashiCorp.
It allows for some fundamental integration and automation with platforms like VirtualBox, Microsoft Hyper-V, VMware, etc. In summary, this is a time-saving tool for standing up VMs faster, configuring them, adding packages to VMs, or integrating your virtual platforms with tools like Ansible.
Building a software prototyping environment (aka lab) is far simpler than ever before. No longer do you have to wait to build a physical machine, then wait to download ISO images of the virtualization stuff, operating systems, software packages etc.
Simply use Vagrant and VirtualBox together. You'll have a highly functional lab for software development up fast with some added agility for prototyping infrastructure choices too.
Note: There are a lot of platforms and starting points for this combination of features and software. For the instructions here, I am using a simple Windows 10 machine and the software available today.
Here's how to use Vagrant and VirtualBox.
First, you'll need to download Vagrant and VirtualBox
This is pretty simple. Nothing special here.
Once you have the two packages and any special dependencies installed, (estimated 10 minutes start to finish), you get to have some fun!
Being about speed, I typically hit the Windows key and start typing power… see the little blue icon highlighted then hit Enter.
If things installed nicely, you should see the highlighted “dot files” in your HOME directory.
I choose vagrant_test as my directory name:
mkdir ~ /vagrant_test
cd ~ /vagrant_test
This example initializes for a generic CentOS7 image from the community-curated generic repo.
vagrant init generic/CentOS7
You should see a new VagrantFile from the init command.
I have another machine visible in the left pane in the screenshot but ignore that.
This makes a new VM from the VagrantFile and definitions we just “initialized” with that init command.
The unique hostname it creates based on the directory we are in (vagrant_test). This command run is the longest part of the process since vagrant is grabbing the image defined (from the internet), building a new VM and getting things all running—but—it is super-fast compared to a normal manual install + setup.
Note: The matching Vagrant VM Name from the previous step. It will create a unique name for each virtual machine you spin up with the VagrantFile.
This takes just a moment.
Note: This uses the VagrantFile and other items in the directory where you have been doing everything (vagrant_test) to make this happen. So, you don’t have to manually deal with SSH keys and external network connections like with Putty, etc.
There are a lot of ways to do this, but I like to run “sudo yum update” to make sure I am current on CentOS box anyway.
sudo yum update
Keeping the environment clean is important since laptop equipment is pretty resource constrained in terms of CPU/RAM and storage capacity.
So, when you are done experimenting with your VM, “vagrant destroy” makes it super easy to clean up quickly.
This deletion process removes the VM and its storage/data but does not delete the VagrantFile that is used to spin up a new machine super-fast (with no data).
Exit your Vagrant VM if you haven’t already.
Note: I execute this command from the same directory where I performed “vagrant up” earlier. The command warns you just in case but know this is going to blow up the VM and all of its data!
This is just the beginning of using this combination of technologies. The combination of Vagrant and VirtualBox should save you lots of time.
Spinning up this CentOS box with Vagrant takes only a couple of minutes because of the automation and other human task elimination. This automated process compares favorably to a typical manual process: 5+ minutes best case to download, 10-15 minutes to install, more time to customize the OS for basic usage (SSH keys, etc.).
I expect I save at least 20 minutes per iteration of spinning up Linux machines in VMs on my laptop with this tooling versus manual methods.
This can equate to hours of productivity gains per day if you do a lot of prototyping like me. Obviously, this type of automation is a big deal in the world of DevOps also. This gets even more impressive when you layer in fancy stuff like Ansible and Kubernetes. Go fast!
OpenLogic provides everything you need to build and manage your open source solutions. You'll get access to an open source support team, available 24×7, to assist you with this updates, implementations, and migrations like this.
Get in touch with an OpenLogic expert today. And learn how we can support your open source solutions, including Vagrant and VirtualBox.
talk to an expert
Senior Sales Engineer and Cloud Architect, OpenLogic
Rick is a passionate technologist and servant-leader with expertise in product management, services, and selling. He brings his expertise of solving challenges with amazing tools and people to his current role on the OpenLogic team.