Share on Social Media

In this guide, you will learn, how to install Vagrant on CentOS 7 along with VirtualBox. #centlinux #linux #vagrant #virtualbox

What is Vagrant? :

Vagrant is an open-source software for easy provisioning of virtual software development environments. The virtual environments called Vagrant boxes are portable in nature and can be used over many platforms without any change. Vagrant is developed by HashiCorp and distributed under MIT License. Vagrant leverages a declarative configuration file which describes all your software requirements, packages, operating system configuration, users, and more.

In this article, we will install Vagrant on CentOS 7 along with VirtualBox. At first, we will install VirtualBox as the provider for Vagrant software, then we will install Vagrant on CentOS 7.

Read Also: How to install Vagrant with KVM on CentOS 8

Vagrant Features:

  • Create complex virtual development environments in a single workflow.
  • Portal development environments, that can be moved to other machines conveniently.
  • Starts a desired development environment with just a single command.
  • A same vagrantfile can be used by all developers to provision their own development environments.
  • Users can create their own custom Vagrant Box or select from the globally available Vagrant boxes of popular software.
  • Easy and Fast.

Vagrant Architecture:

Vagrant uses Provisioners and Providers as building blocks to create and manage the development environments.

  • Provisioners are tools to customize the virtual environments e.g. Puppet, Chef, Ansible, etc.
  • Providers are the services that Vagrant uses to setup and create virtual environments e.g. VirtualBox, Docker, Hyper-V, etc.

Vagrant creates a layer on top of the virtualization software and allow the users to manager development environments with just a single vagrant command. Machine and software requirements are defined in vagrantfile, to execute necessary steps to create a development-ready box.

Box is a format and an extension (.box) for Vagrant environments, and it is portable across various platforms.

Vagrant System Requirements:

Vagrant has no special hardware and software requirements except that it requires a Provider to create development environments.

Environment Specification:

We have provisioned a CentOS 7 based system with following specifications:

  • Hostname –
  • IP Address – /24
  • Operating System – CentOS 7.6
  • CPU – 3.4 Ghz (2 Core)
  • Memory – 2 GB
  • Storage – 20 GB

Install VirtualBox on CentOS 7:

Connect with using ssh as root user.

Install prerequisite software packages using yum command.

# yum install -y kernel-devel-$(uname -r) kernel-headers gcc make perl wget

We have used $(uname -r) with above yum command. It demands a little clarification.

The vboxdrv.service requires same kernel-devel modules as of running Kernel. Otherwise, after installation vboxdrv.service will give you following errors.

# tail /var/log/messages
Jun 16 11:22:05 vagrant-01 Building VirtualBox kernel modules.
Jun 16 11:22:06 vagrant-01 This system is currently not set up to build kernel modules.
Jun 16 11:22:06 vagrant-01 Please install the Linux kernel "header" files matching the current kernel
Jun 16 11:22:06 vagrant-01 for adding new hardware support to the system.
Jun 16 11:22:06 vagrant-01 The distribution packages containing the headers are probably:
Jun 16 11:22:06 vagrant-01 kernel-devel kernel-devel-3.10.0-957.el7.x86_64
Jun 16 11:22:06 vagrant-01 systemd: vboxdrv.service: control process exited, code=exited status=1
Jun 16 11:22:06 vagrant-01 systemd: Failed to start VirtualBox Linux kernel module.
Jun 16 11:22:06 vagrant-01 systemd: Unit vboxdrv.service entered failed state.
Jun 16 11:22:06 vagrant-01 systemd: vboxdrv.service failed.

Therefore, we have used $(uname -r) command to suffix the Kernel version with the yum command for the desired result.

VirtualBox is a free and open-source Hypervisor, developed by Oracle Corporation.

VirtualBox’s yum repository configurations are available at VirtualBox Official Website.

Therefore, we will first add VirtualBox’s yum repository in our CentOS 7 server and then we will install VirtualBox using yum command.

First of all, we have to import Oracle public key in our CentOS 7 server.

Download Oracle public key as follows.

# cd /tmp
# wget
--2019-06-16 10:29:47--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1734 (1.7K) [text/plain]
Saving to: âoracle_vbox.ascâ

100%[======================================>] 1,734       6.44KB/s   in 0.3s

2019-06-16 10:29:51 (6.44 KB/s) - âoracle_vbox.ascâ saved [1734/1734]

Import Oracle public key in our CentOS 7 server.

# rpm --import oracle_vbox.asc

Download and add VirtualBox yum repository in our CentOS 7 server.

# wget -O /etc/yum.repos.d/virtualbox.repo
--2019-06-16 10:32:01--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 259 [text/plain]
Saving to: â/etc/yum.repos.d/virtualbox.repoâ

100%[======================================>] 259         --.-K/s   in 0s

2019-06-16 10:32:04 (1.02 MB/s) - â/etc/yum.repos.d/virtualbox.repoâ saved [259/259]

Build yum cache for newly added repositories.

# yum makecache fast
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * extras:
 * updates: [Errno 14] curl#7 - "Failed connect to; Connection refused"
Trying other mirror.
base                                                     | 3.6 kB     00:00
extras                                                   | 3.4 kB     00:00
updates                                                  | 3.4 kB     00:00
virtualbox/7/x86_64/signature                            |  181 B     00:00
Retrieving key from
Importing GPG key 0x98AB5139:
 Userid     : "Oracle Corporation (VirtualBox archive signing key) <>"
 Fingerprint: 7b0f ab3a 13b9 0743 5925 d9c9 5442 2a4b 98ab 5139
 From       :
Is this ok [y/N]: y
virtualbox/7/x86_64/signature                            | 2.9 kB     00:04 !!!
virtualbox/7/x86_64/primary_db                             | 130 kB   00:00
Metadata Cache Created

Install VirtualBox on CentOS 7 using yum command.

# yum install -y VirtualBox-6.0

vboxdrv.service is automatically enabled and started by VirtualBox installation process.

Check status of vboxdrv.service.

# systemctl status vboxdrv.service
â vboxdrv.service - VirtualBox Linux kernel module
   Loaded: loaded (/usr/lib/virtualbox/; enabled; vendor preset: disabled)
   Active: active (exited) since Sun 2019-06-16 11:28:47 PKT; 10min ago
  Process: 39778 ExecStart=/usr/lib/virtualbox/ start (code=exited, status=0/SUCCESS)

Jun 16 11:27:27 systemd[1]: Starting VirtualBox Linux ...
Jun 16 11:27:27[39778]: Startin...
Jun 16 11:27:27[39778]: Buildin...
Jun 16 11:28:47 systemd[1]: Started VirtualBox Linux k...
Hint: Some lines were ellipsized, use -l to show in full.

Install VirtualBox Extension Pack:

VirtualBox is split into two components.

  • Base Package
  • Extension Packs

We have already installed VirtualBox Base Package above. Now, we are installing VirtualBox Extension Pack to extend the functionality of VirtualBox software.

VirtualBox Extension Pack is available at VirtualBox Official Website.

There is a single universal package of VirtualBox Extension Pack available that supports all platforms.

Therefore, we are downloading it using wget command.

# wget
--2019-06-16 11:53:23--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 23309069 (22M) [text/plain]
Saving to: âOracle_VM_VirtualBox_Extension_Pack-6.0.8.vbox-extpackâ

100%[======================================>] 23,309,069   595KB/s   in 40s

2019-06-16 11:54:06 (570 KB/s) - âOracle_VM_VirtualBox_Extension_Pack-6.0.8.vbox-extpackâ saved [23309069/23309069]

Install VirtualBox Extension Pack using VBoxManage command.

# VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.0.8.vbox-extpack
VirtualBox Extension Pack Personal Use and Evaluation License (PUEL)

License version 10, 20 July 2017

Do you agree to these license terms and conditions (y/n)? y

License accepted. For batch installation add
to the VBoxManage command line.

Successfully installed "Oracle VM VirtualBox Extension Pack".

VirtualBox 6.0 and VirtualBox Extension Pack have been successfully installed on CentOS 7 server.

Install Vagrant on CentOS 7:

To install Vagrant on CentOS 7, we need to install following prerequisite packages.

# yum install -y rsync

Latest version of Vagrant is available on Vagrant Official Download Page.

Download Vagrant RPM using wget command.

# wget
--2019-06-16 12:05:28--
Resolving (, 2a04:4e42:2::439
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 40824607 (39M) [application/x-redhat-package-manager]
Saving to: âvagrant_2.2.4_x86_64.rpmâ

100%[======================================>] 40,824,607   566KB/s   in 73s

2019-06-16 12:06:41 (549 KB/s) - âvagrant_2.2.4_x86_64.rpmâ saved [40824607/40824607]

Install Vagrant on CentOS 7 by using rpm command.

# rpm -ivh vagrant_2.2.4_x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:vagrant-1:2.2.4-1                ################################# [100%]

Create a home directory to store Vagrant projects.

# mkdir ~/vagrant-home
# cd ~/vagrant-home/

Create a new project directory and create a vagrantfile therein for Alpine Linux.

# mkdir alpine
# cd alpine
# vagrant init generic/alpine38
A `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
`` for more information on using Vagrant.

We have initialized a new Vagrant project with generic/alpine38 vagrant box.

You can find a Vagrant box as per your choice of operating system and application software at Discover Vagrant Boxes.

Start the Vagrant Project using vagrant command.

# vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'generic/alpine38' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'generic/alpine38'
    default: URL:
==> default: Adding box 'generic/alpine38' (v1.9.14) for provider: virtualbox
    default: Downloading:
    default: Download redirected to host:
==> default: Successfully added box 'generic/alpine38' (v1.9.14) for 'virtualbox'!
==> default: Importing base box 'generic/alpine38'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'generic/alpine38' version '1.9.14' is up to date...
==> default: Setting the name of the VM: alpine_default_1560671657772_73973
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...

Conclusion – Install Vagrant on CentOS 7:

In this guide, you have learned, how to install Vagrant on CentOS 7 along with VirtualBox. Before using Vagrant, we recommend that you should read Vagrant: Up and Running (PAID LINK) by O’Reilly Media to have a thorough understanding of Vagrant concepts and command usage.

2 thoughts on “How to install Vagrant on CentOS 7”
  1. after vagrant run commant,

    There was an error while executing `VBoxManage`, a CLI used by Vagrant
    for controlling VirtualBox. The command and stderr is shown below.

    Command: ["startvm", "f98d8452-e049-4f65-a37a-4a1cdfe8bdd8", "–type", "headless"]

    Stderr: VBoxManage: error: VT-x is not available (VERR_VMX_NO_VMX)
    VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component ConsoleWrap, interface IConsole

  2. Your machine does not support VT-x or virtualization. If you are executing above steps on a virtual machine then you have to enable virtualization support from VM settings.

Leave a Reply

Your email address will not be published. Required fields are marked *