How to create a Centos 7.0 Vagrant Base Box

This tutorial is aimed at allowing you to create a Vagrant base box which contains Centos 7.0. Vagrant allows you to create and share virtual machines with anybody. There are two ways of using Vagrant boxes, either you create them or you can import one. You can import one from the internet or any other medium. In this tutorial I will show you how to create your own Centos 7.0 Vagrant box. I usually create my own boxes as it allows me to only install the software that I need or want.

Tools you will need:

* VirtualBox –
* Centos 7.0 –

Let’s begin

1. If you haven’t done so already, download and install VirtualBox (

2. Download Centos 7.0 ( For the purpose of this tutorial I will be using the NetInstall ISO, but you may use any other ISO. I selected the NetInstall because of it’s small file size.

3. Create a new VM with VirtualBox. I have named mine centos7-vagrant.

VirtualBox Name

You may setup this box any way you want. As far as settings are concerned, I have selected the following settings:
– Memory: 2GB
– Hard Disk: 20GB fixed size

Memory Size
Memory Size
File Type
Hard drive file type
Fixed Size
Storage on physical hard drive
Drive Size
File location and size

4. Once your VM has been created go ahead and boot it up. It will ask you for a start-up disk. In my case I downloaded the NetInstall ISO. So I browsed and select CentOS-7.0-1406-x86_64-NetInstall.iso

Select Startup Disk
Select Startup Disk

5. Install Centos with any parameters you want. I selected a minimal install since I just want the basics and any special package that I need will be installed later.

Installation Summary
Installation Summary

6. Set the root password as “vagrant”.

Root Password
Root Password

7. Create the vagrant user. Set the username and password to “vagrant”

Create User
Create User

8. Once installation is finished and the VM restarts, login as root.

9. Now would be a good time to install the VirtualBox Guest Additions. NOTE: This is an optional step.

10. Now we need to install packages that are essential for Vagrant to operate within the VM.

11. Let’s enable some services at startup time. We need ntpd so that it sets the time up correctly every time you boot up the Vagrant box, and of course sshd in order to SSH in.

12. Disable iptables as it really is not needed for a Vagrant box. It would just get in the way.

13. Set SELinux to permissive mode.

14. Comment out requiretty in /etc/sudoers. This will allow Vagrant to apply changes during startup.

15. Add the vagrant user to /etc/sudoers file.

16. Create /etc/sysconfig/network-scripts/ifcfg-eth0 and add the following:

17. We must now add a public key for the vagrant user. You can use the default public key or create a custom one. You may find more information on how to create a custom vagrant public key in the following tutorial “Using custom Vagrant SSH public/private keys“. For now we are going to use the readily available vagrant public key.

Create .ssh folder on the home directory:

Copy publick key:

curl >> /home/vagrant/.ssh/authorized_keys

Set the correct permissions:

Make sure everything is owned by the correct use:

18. Turn off the VM

19. To create your Vagrant Box you will need to package the VM you just created. The following command will package the VM into your home directory. You are free to change this directory by modifying the –output paramenter

The –output would be the destination of your Vagrant Box file, and –base is the name or UUID of the VM that was created using VirtualBox.

20. Create the Vagrantfile

21. Start the Vagrant VM


If all the steps where followed correctly then your vagrant box is up and running. To login to the machine just do


Leave a Reply