What is VirtualBox and Vagrant ? an introduction

Let’s get started with VirtualBox and Vagrant for creating development environments. This is a fair warning: Should you choose to venture down this path, you are most definitely entering the full blown world known to the hackers as DevOps. DevOps is where dreams go to die. Here at Vegibit, we’ve tended to focus on the fun aspects of Web Development. Things like creating HTML, programming PHP, programming JavaScript and jQuery, designing layouts, and dabbling with full stack frameworks like Laravel, Yii, and Codeigniter. DevOps is a whole different ball game. Much of this knowledge is the precursor to getting up and running with Laravel Homestead. If you’re new to VirtualBox or Vagrant however, do yourself a favor and skip homestead for now. Learn the basics first, you’ll soon see why.


What Is DevOps?

Thinks of DevOps like this. You want to build a website, but you know there are quite a few steps. It might look something like this.

Goal: Develop a Website.

  • 1. Choose language.
  • 2. Choose Server Type.
  • 3. Choose backend framework.
  • 4. Choose frontend framework.
  • 50. Write some HTML.

So you can see we have a lot of steps to actually create a website, and most of them don’t even have to do with actually creating the site! Well the DevOps folks are responsible for steps 1 through 49. In fact, in the most likely scenario, and especially if you work for someone that doesn’t understand this stuff, or you are a one person freelance phenomenon, DevOps is simply part of what you do as a Web Developer. Wow. Aren’t you glad you decided to get into developing websites?


Virtualization Is An Investment

All of this technology revolves around Virtualization. Virtualization is the buzzword of our generation, and seemingly everything in computing can be virtualized. Entire new businesses and paradigms have been created on the back of virtualization. Think of things like VMWare, EC2 instances, AWS hosting, Rackspace Hosting, or even things like hosted VoIP, or various enterprise SAAS software as a service offerings. All of these things run as virtualized machines running in the cloud. Virtualization is good for Infrastructure Consolidation, Testing, Disaster Recovery, and running several operating systems on the same machine at the same time. Entire careers are built upon nothing more than being an expert at Virtualization, so if some of this seems a bit overwhelming at first, no need to fret. Learning this stuff absolutely takes a large investment of time, and to actually get good at this stuff requires the initial investment, and then ongoing practice with daily use in your workflow. Hopefully this introductory guide to Virtualization, VirtualBox, and Vagrant will help with this. For a more thorough overview of Virtualization check out the VirtualBox Manual for some great information.


Beware VirtualBox and Windows Operating Systems!

Now we’re going to put rubber to road. We’re going to actually start installing all of this stuff on a brand new Lenovo T440s with SSD drives, plenty of memory and cpu cycles, Windows 7, and all the bells and whistles. Basically, a really nice ultrabook, or the WinTel version of something like a Macbook Pro. With such hardware in place, what could possibly go wrong?!

The Matrix

So what does the matrix have to do with this? Well, if you recall (and if you haven’t seen The Matrix, please stop reading now) in the original Matrix, Neo gets a chance to find out what is real vs what is an illusion. The illusion of course is the Matrix, nothing more than a virtual world created by machines. Neo has a choice between a red or a blue pill. Blue is the blissful ignorance of illusion while Red is the painful truth of reality. When getting started with Virtualization, VirtualBox, and Vagrant, you may be faced with a similar choice. For myself, Virtualization looked wonderful and tempting to me. Yet, like in the Matrix, I knew something just didn’t feel right. This something is what made me decide it was time to take the Red Pill and find out what is really behind the Virtualization curtain.

The Blue Pill Virtualization Story

The blue pill version of setting up these tools is truly a wonderful story, albeit an illusion. It goes something like this.

“All you have to do is install VirtualBox and Vagrant on your machine! It’s so amazing! We now have the ideal development environments! Ok, you installed Vagrant?! All you have to do is type vagrant up and your life is now perfect!”

Holy Crap! I need to get my hands on this Vagrant VirtualBox combination you speak of! I can’t wait to start!

The Red Pill of Virtualization

Friend, you now work in DevOps. You don’t work in Sales and Marketing where promises are made, and life is perfect. No, as a good techie, you always opt for the Red Pill. You must face the painful reality and truth of making disjointed things work every single day. There are always problems. Inconsistencies. Bugs. Beta Software. Old Software, that still sucks. Underpowered hardware. It doesn’t matter, for you are the modern day Macgyver of DevOps, turning underfunded terrible ideas into wonderful functional assets to the company. You are a hero. With that in mind, we will now explore the painful truth of getting things running.

Install Virtual Box

Ok first up it looks like we need a copy of virtualBox. Looks like we can get it right here, so let’s do that. At the time of this writing it looks like 4.3.20 is the current build. We’ll go with that.

Install Git With Git Bash

We’re going to need to create an SSH key as well as a nice terminal to work with. Git Bash is perfect for this, and all we have to do is visit this site to download it now.

Install Vagrant

Now we can install the great Vagrant Tool. Just visit their downloads section and download the installer.

Running The Installers

If there is anything I can’t stand, it’s adding new software to a brand new, super fast running and clean PC. You know the feeling, “is something going to break? Will things slow down? Will something break I don’t know about, only to uncover some type of problem weeks later that impacts my daily work?” No matter. We must push forward in the face of fear. Run all of the prior listed software installer packages and move boldly into the world Virtualization for yourself.

Hell Begins
Ok, at this point, we’re probably going to need to reboot the PC. One or more of the prior installers is asking for it, so let’s do that now. Close all open programs, save any open files, reboot.

Perfect. We’re back up. We can now simply type two commands at the terminal according to the documentation, and we’re good to go. First off, what terminal? Is this the command prompt of Windows? Are we using putty for this? What about Git Bash? For this, we want to use Git Bash. Find the program in your list of installed programs and run it. Now assuming you have placed your Vagrant install in C:vagrant, we’ll want to cd into that directory from Git Bash like so.

$ cd c:/vagrant

Now let’s run those commands.

$ vagrant init hashicorp/precise32

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.

Looks good. Let’s try the infamously easy vagrant up.

$ vagrant up

Bringing machine ‘default’ up with ‘virtualbox’ provider…
==> default: Importing base box ‘hashicorp/precise32’…
==> default: Matching MAC address for NAT networking…
==> default: Checking if box ‘hashicorp/precise32’ is up to date…
==> default: Setting the name of the VM: vagrant_default_1419987513948_16273
==> default: Clearing any previously set network interfaces…
==> default: Preparing network interfaces based on configuration…
default: Adapter 1: nat
==> default: Forwarding ports…
default: 22 => 2222 (adapter 1)
==> default: Booting VM…

Five minutes have passed. Is it supposed to stay at Booting VM for this long? Oh wait, here is a nice error message.

Update The Bios!

Ah ha! I must have forgot to update the bios on this Windows PC. It did mention somewhere or other that we might need to enable virtualization in the bios. How do we do that again? I don’t mess with the bios very often. Oh yeah, let’s reboot and keep tapping the Enter key until we hear beeps indicating we have halted the normal boot process. Perfect, now choose F1 for bios setup, arrow to the right a few times until we hit the security menu, arrow down until we reach virtualization, then choose F10 to save and boot.

Yes! I can’t wait to try my new virtualization. Now that we are booted back up, let’s try our vagrant up again.

$ vagrant up

Bringing machine ‘default’ up with ‘virtualbox’ provider…
==> default: Importing base box ‘hashicorp/precise32’…
==> default: Matching MAC address for NAT networking…
==> default: Checking if box ‘hashicorp/precise32’ is up to date…
==> default: Setting the name of the VM: vagrant_default_1419987513948_16273
==> default: Clearing any previously set network interfaces…
==> default: Preparing network interfaces based on configuration…
default: Adapter 1: nat
==> default: Forwarding ports…
default: 22 => 2222 (adapter 1)
==> default: Booting VM…

Twiddling Thumbs. Hmm, sure does seem to still be taking a long time. Oh wait, here we go, more error messages. Looks like they are the same as before. What the? What is wrong? Oh wait, I did notice there were two options for virtualization in the bios. There was Intel R virtualization Technology and Intel R VT-d Feature. We only enabled the first one. Let’s enable the second one just in case, I mean what else could be going wrong? Ok, save all open files, close open programs, reboot PC…

We’re starting to boot, hit that return button multiple times! We now hear beeps – the boot process is halted. Let’s modify the bios again. Hit F1, arrow over to Security, arrow down to Virtualization, this time choose Intel R VT-d Feature and set to enabled. Select F10 to save and boot. Perfect. A couple hiccups, but we’re on our way to Virtualization Nirvana.

And, we’re back. Let’s go ahead and try a vagrant up one more time.

$ vagrant up

Bringing machine ‘default’ up with ‘virtualbox’ provider…
==> default: Importing base box ‘hashicorp/precise32’…
==> default: Matching MAC address for NAT networking…
==> default: Checking if box ‘hashicorp/precise32’ is up to date…
==> default: Setting the name of the VM: vagrant_default_1419987513948_16273
==> default: Clearing any previously set network interfaces…
==> default: Preparing network interfaces based on configuration…
default: Adapter 1: nat
==> default: Forwarding ports…
default: 22 => 2222 (adapter 1)
==> default: Booting VM…

Still kinda slow here. Man these VM’s take a long time to boot. WHAT THE [email protected] WHAT’S WITH THESE ERROR MESSAGES?!

Proceed to Google. Google anything and everything related to VMs not launching using VirtualBox and Vagrant.

Ah ha, I may have spotted something. Looks like those Microsofties made a mistake. Looks like there an update they released, KB3004394, that breaks a bunch of things, and this happens to be one of them. Thankfully, they have released a patch to fix this trouble right here. Awesome. No harm, no foul. We’ve had a few troubles, but if we just install this nice little Windows Patch, we will finally be able to get up and running with Vagrant and VirtualBox on our Windows Box. Ok, we download the update as a .exe executable and run it. Hmm, that was easy, nothing really happened. Well, it’s installed we must be good to go, let’s vagrant up.

$ vagrant up

Bringing machine ‘default’ up with ‘virtualbox’ provider…
==> default: Importing base box ‘hashicorp/precise32’…
==> default: Matching MAC address for NAT networking…
==> default: Checking if box ‘hashicorp/precise32’ is up to date…
==> default: Setting the name of the VM: vagrant_default_1419987513948_16273
==> default: Clearing any previously set network interfaces…
==> default: Preparing network interfaces based on configuration…
default: Adapter 1: nat
==> default: Forwarding ports…
default: 22 => 2222 (adapter 1)
==> default: Booting VM…

This POS is still not working. THERE ARE GOING TO BE PROBLEMS AROUND HERE IF WE DON’T GET THIS WORKING!

Well, let’s think about this. The Microsoft website said we might, or might not need to reboot once the patch is installed. You know, we didn’t reboot. Maybe that’s the problem. Let’s reboot again to make sure the patch took. Close all open files, save your work. Close all open programs. Reboot.

And we are once again live. What a process. It hasn’t been easy, but this will surely fix us right up now that we have the patch installed AND we rebooted the PC yet again for safe measure. It’s vagrant up time baby.

$ vagrant up

Bringing machine ‘default’ up with ‘virtualbox’ provider…
==> default: Importing base box ‘hashicorp/precise32’…
==> default: Matching MAC address for NAT networking…
==> default: Checking if box ‘hashicorp/precise32’ is up to date…
==> default: Setting the name of the VM: vagrant_default_1419987513948_16273
==> default: Clearing any previously set network interfaces…
==> default: Preparing network interfaces based on configuration…
default: Adapter 1: nat
==> default: Forwarding ports…
default: 22 => 2222 (adapter 1)
==> default: Booting VM…

I can’t even talk. It is still broken.

Back to Google. Time to Google the living life out of this issue.

15 Google Searches later. We may have found something. Some users are reporting problems with various Windows Machines booting VMs using the 4.3.20 build of VirtualBox. Some have even reported that doing a backrev to a prior build may help. Ok, sounds reasonable, let’s uninstall the current VirtualBox, so we can then install the prior version of VirtualBox which is 4.3.18. This has really sucked, but I’m sure this will fix things so that we can finally start working with our new VMs. Let’s uninstall VirtualBox, ok Windows is asking if we really want to do this, and should we allow Oracle Corporation to modify the machine, sure, let’s uninstall.

Ten minutes later…

This POS uninstall program has now hung. Let me just cancel it. What THE!? “Another program is trying to install a program, please wait for the other process to finish”

I got this. ctrl alt delete, find the VirtualBox task, and end that sucker. Ok, I’m clicking END TASK, but the process is sill running. Ok, let’s just click END TASK 10 times in a row. Nope. Process still running. VirtualBox has taken over my PC. Just Reboot the PC and try again. Start->Shut Down…

5 minutes later… The text “Shutting Down PC” has now been on the screen for over 10 minutes. Great. Now I can’t even get this POS PC to turn off. Press and hold power button until all the life leaves this damn machine. Finally. Power back up. We’re now seeing the warning that Windows may have not shut down correctly, and we might need to start in safe mode and scan some files for integrity. Yeah, that’s not happening. Choose the start windows normally option. Try to uninstall VirtualBox one more time. Yes!! It worked! We were able to uninstall VirtualBox 4.3.20. Let’s go ahead and install this handy 4.3.18 version of VirtualBox and GET THIS VIRTUALIZATION PARTY STARTED!

Now that we have 4.3.18 installed, and rebooted the PC more times than I’m able to count, I’m positive that we will now be working perfectly with virtualization once we simply type vagrant up.

$ vagrant up

I’ll spare you the pain. The piece of junk is still not working. Back to Google.

15 minutes later…

We might have found something. I’m reading that ever since 4.3.14 for VirtualBox, there have been various problems with booting VMs due to various security issues, and potential anti virus conflicts. I’m not sure I even have it in me to try anymore. We’re several hours deep into this mess. I’ll give it one more shot. Let’s download the 4.3.12 version from May of 2014 and try again. What could we possibly have to lose? I mean, this day is shot anyways, so…

Everything is installed. Vagrant is installed. VirtualBox 4.3.12 is installed. I’m weary, but I will carry on. I will vagrant up one more time.

It worked. Finally.

virtualbox

Conclusion

Guys, this was just a fun post to rant like a madman for fun. I actually believe in the virtues of Virtualization and the new way of doing things with Vagrant and VirtualBox. I’m going to keep my eyes peeled on the VirtualBox website for updates as there is clearly something amiss with Windows and VirtualBox on the 4.3.20 build. In the mean time, we’ll be using 4.3.12. I do hope you found this rant comical!

About the author

Deven Rathore

I'm Deven Rathore, a multidisciplinary & self-taught designer with 3 years of experience. I'm passionate about technology, music, coffee, traveling and everything visually stimulating. Constantly learning and experiencing new things.

Pin It on Pinterest

Shares

Get the best in web dev

Join dunebook.com and recieve best in web dev , once a week FREE

An email has been Sent to your Inbox ! Please Confirm your Subscription :)