CentOS minimal install using Vagrant and Virtualbox

I got introduced to vagrant when I was at the puppet training this month. An awesome tool that let’s you customize and deploy a vm on a provider like VMware workstation, oracle virtualbox etc. I will not go into the details of explaining what it is and how it works because their documentation covers pretty much everything you need to know and get started.

I was pretty impressed at first when i saw how it worked. Like most people I use it with my virtualbox as it comes free. This blog post is intended towards those folks who have not tried it yet and would like to. I will not be doing any complex implementation here. Just a small CentOS box which is pre-built and available and we will deploy it on virtualbox using vagrant.

Before we get to the deployment part, we need three things in place. Virtualbox, vagrant and git. All three installation are pretty straight forward. The links for all three are here.

Virtualbox |  Vagrant  |  Git for Windows

Once the installation is done, reboot the system. A system with 8 GB RAM and a quad core processor is more than enough to run this setup.

The next step can be performed two ways, one by downloading the vagrant box and initializing it or adding the box directly through it’s URL.

We will add the box from it’s url using “vagrant box add <url>”

Vagrant - 1

This will take a while depending on your internet speed.

If you want to download it and then initialize it, you can download the vagrant box, place it in the above folder and then run the “vagrant init <box name>” command.

Vagrant - 2

This will create a vagrantfile in the same folder which can be used to customize the VMs that are deployed using this base box.

Edit the vagrantfile and add a hostname for the server as shown below.

Vagrant - 3

The VM deploys with a default NAT interface. If you need an extra private network you can select the line that configures private network and un-comment it.Vagrant - 4

Now that we have made some minimal changes, we can go ahead and type “vagrant up” which will bring up the machine and customize it.Vagrant - 5

You will face the below error if Intel-VT/AMD-v is disabled on your system. Restart and enable it so you can run x64 OSes.

Vagrant - 6

And that is it! The machine is up and running with the required config. Run “vagrant ssh” to connect to the deployed server.

Vagrant - 7

And you can see that a machine is up and running on your virtual box with all the customization you input.Vagrant - 8

This is just an example and you can build any OS in the same way. This is not just for a single machine but can be used to build multi machine environments too.

Hope this was an useful post. Have feedback? Drop it in the comments section.

The vagrantfile Code that I used can be found here.

Leave a Reply