Setting Up Vagrant CentOS 7 with Virtual Box Guest Additions

setting up vagrant centos7 with virtual box guest additions

Why Guest Additions?
– mount local hard drive to vm
– copy and paste between host and vm

Why VBox version 4.x when there’s 5.x?

I am on Mac OS X El Captian and VirtualBox 5.x didn’t work for me.

I installed VBox 5, setup CentOS7 through VBox’s GUI, and it fails to start with some “session” error.

I then installed VBox 4.30, and CentOS7 worked like a charm, EXCEPT I couldn’t get the Guest Addition running, nor could I get the bridged network / port forwarding working to allow me to ssh from Mac terminal to the VM.

So I head to vagrant boxes, which gives significant benefit for my use case beside it’s another option to try. I can skip the installation screen and get a centos up and running in minutes! I will need a few of those boxes, so not having to repeat installation is definitely a plus.

There are vagrant box that has guest addition preinstalled, but call me paranoid, I want to use the official centos7 image.

Once you have your centos box up by running these in your terminal

vagrant up
vagrant ssh

Run following script:


# install virtualbox guest addition on centos VM

sudo yum -y update
sudo yum -y install wget kernel-headers-$(uname -r) kernel-devel gcc* 
cd /opt
sudo wget -c -O VBoxGuestAdditions_4.3.40.iso

cd /opt
sudo mount VBoxGuestAdditions_4.3.40.iso -o loop /mnt
cd /mnt
sudo sh --nox11

sudo reboot


To mount your drive permanently, add following line to Vagrant file

 config.vm.synced_folder "/hostpath", "/vmpath"

where “/hostpath” is the folder from my host that I want to share with the VM, and “/vmpath” is how I can access the shared folder from within the VM.

vagrant reload

vagrant up

vagrant ssh

You can now access the shared folder by going to your value set in “/vmpath”