Installing VirtualBox and Vagrant on Windows 10

Shamli Singh
3 min readFeb 9, 2019

--

Recently I have been working on a small full-stack application, where I also wanted to implement a JSON endpoint. More on that in a later post! But somehow all this required me to have a virtual environment solution. This is where VirtualBox comes into picture.

VirtualBox is probably a new term for most of you out there, but it is on the similar lines of VMware, docker and other vendors that offer operating-system level virtualization services for software development — or Container, to be generic! It is offered by the age-old Oracle.

VirtualBox usually goes hand-in-hand with Vagrant — an open-source software product by HashiCorp for building and maintaining portable virtual software development environments. So it acts as an agent that simplifies all the virtual environment configurations, meaning that developers can focus on developing and be more productive.

There are numerous blogs out there that explain this, but very few that simplify the installation process for people like me — who are always in hurry to jump to building solutions sans the expense of energy on configuration.

Getting ready…

Before jumping into installation, it would be a good idea to go through the above links and understand how VirtualBox and Vagrant work. Later is fine though!

Download the installation file for VirtualBox here — I’m using the latest i.e. 6.0.4 build. Also download for Vagrant here — I’m using 2.2.3.

Note: Just browse a little to make sure that your version of VirtualBox is compatible with your Vagrant, as this may cause issues later.

Begin installing!

Now that you have the installers, first install VirtualBox and then go for Vagrant (although the order doesn’t really matter, as we’ll be configuring it later).

You’ll need to work a little on the terminal (or it’s equivalent on Windows). A git bash would be preferable. Don’t worry, if you don’t have it, I suggest you check out my post which explains its installation!

After installation

Create a directory where we can have our VM, and then move into it

$ mkdir mydirectory
$ cd /mydirectory

We’ll install a Ubuntu 14.04 server as our VM

$ vagrant box add ubuntu/trusty64

After a few moments, if this was successful, it will say so in the output. Then

$ vagrant init ubuntu/trusty64

This initializes our VM. The output should go as:

`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.

Great! Now you are ready to get the VM running:

$ vagrant up

When you see…

Bringing machine 'default' up with 'virtualbox' provider... 
==> default: Importing base box 'ubuntu/trusty64'...
... ==> default: Machine booted and ready!

it means that the VM is in place successfully!

Start the VM

Now that the VM is ready to go, start it from the bash itself

$ vagrant ssh

If the installation was done properly, you should see something like below:

Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-123-generic x86_64)   * Documentation:  https://help.ubuntu.com/    

System information as of Sun Jul 2 21:30:05 UTC 2017
...vagrant@vagrant-ubuntu-trusty-64:~$

You are in! Type exit to exit the server, and vagrant halt to shut it down.

If you ran into this error:

==> default: Checking for guest additions in VM...     
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.

This wouldn’t be a problem right now, but it may be in the long run. Read more about it here.

To get rid of it, first shut down the currently running Vagrant.

$ vagrant halt

Then quickly install the required plugin

$ vagrant plugin install vagrant-vbguest

After it finishes running through more commands, it’s time to reload:

$ vagrant reload

Now the errors should be gone:

[default] GuestAdditions 5.1.22 running --- OK.

You have successfully installed VirtualBox and Vagrant, which are now ready to use!

--

--

Shamli Singh

MS Computer Science student at San Jose State University, Newbie at blogging, Fascinated with amazing tech! GHC 2020