How to add,install and run CentOS 7 Vagrant box to Virtualbox using Vagrant

Posted on 212 views

Hello guys. Today we’ll look at How to install centos 7 box with vagrant on virtualbox. Below are the steps to follow
1) First download the Centos 7 vagrant box from the link Direct Link to download the CentOS 7 box
Once the download is complete, create a vagrant folder on your home directory

 mkdir -p ~/vagrant/centos7
 cd ~/vagrant/centos7

2)Now copy the downloaded centos7 vagrant box and put it in the directory you just created.
3) You should have the vagrant already installed, if not installed download vagrant and install it.
For my case, i am using vagrant 1.7.4 and Virtualbox 5.0. Have a look at How to install Virtualbox Latest on Ubuntu and Kali Linux
Now open the terminal as standard user and cd to directory containing vagrant centos7 box
4) Add the centos7 box by typing the following command

     vagrant box add --name centos7

Replace centos7 by the name you want the box to have and by the name of the box you downloaded.
If the Virtual machine was created on Virtualbox,You’ll should see the message, ” The box successfully added to Virtualbox”
5) Now create Vagrantfile needed to start the vm by typing”

     vagrant init


6)  Edit the Vagrantfile and replace the name of box inside the file with the name you specified in the –name option while creating the vm from the box file.For my case the name is centos7. Use any editor you like, make changes and save them to the file.

vim  Vagrantfile




7) Now it’s time to start the added box. Use the command

   vagrant up

8) Login to the CentOS 7 Virtual Machine with the command

     vagrant ssh

You can see that i have successfully login to the Centos 7 box on Virtualbox from the Screen-shot below. You can do system update and upgrade.




9) Next time you want to ssh in to the Centos 7 box added, just cd to the directory you created and  do

 vagrant ssh

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.