Setting up Vagrant on CentOS 7

I’m currently running a CentOS 7 “Server with GUI” and all of the default Virtualization Groups installed as my “Desktop.”  This procedure was tested on a fresh install.

1.)  Verify that the installed version of kernel-devel matches the kernel that you’re currently running.  If you don’t have kernel-devel installed, make sure that there is a version that matches your current kernel present in your normal repository for use.

Note:  If you don’t have kernel-devel installed and the versions don’t match before you start, you will receive an error message during the VirtualBox install.  This is because there is a mismatch between the running Kernel and the Kernel Headers that are being used to build the VirtualBox kernel modules.

# yum info kernel kernel-devel

If your current kernel doesn’t match the available version of kernel-devel, you’ll need to update your kernel to something more current so they can match when it’s time to build the VirtualBox kernel modules.

# yum install kernel

Note:  Remember, we want to install the Kernel, not update it.  That way if there’s a problem we have a way to get back into the old Kernel from the Grub menu.  (We can always remove the old Kernel afterwards.)

While you’re at it, you might also want to just update all of the packages on your server.

# yum update

2.) If you updated your kernel, don’t forget to reboot your server.

3.) Download and Install Vagrant

https://www.vagrantup.com/downloads.html

4.) Download and Install VirtualBox

https://www.virtualbox.org/wiki/Linux_Downloads

Note: If you’re running a 64 Bit Kernel, use the AMD64 Package even if you’re on an Intel box.

Note:  Yes, I know you can change the Vagrant provider so it uses KVM instead of VirtualBox.  But I was trying to go with a stock Vagrant install since I’m using it for some labs.

If you received an error during installation matching the one I received at the bottom of this post, proceed onto the next two steps.

5.) Install the gcc and kernel-devel Packages.

# yum install gcc kernel-devel

Note:  Remember the first step?  We’ll want to make sure that the version of kernel-devel matches the kernel that you’re currently running.

6.) Run vboxconfig

# vboxconfig

Example of Error Received during Installation because kernel-devel is not present or does not match the currently installed kernel.

##########
Running transaction
Installing : SDL-1.2.15-14.el7.x86_64 1/2
Installing : VirtualBox-5.2-5.2.12_122591_el7-1.x86_64 2/2

Creating group ‘vboxusers’. VM users must be member of that group!

This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.
Please install the Linux kernel “header” files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
kernel-devel kernel-devel-3.10.0-862.2.3.el7.x86_64
This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.
Please install the Linux kernel “header” files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
kernel-devel kernel-devel-3.10.0-862.2.3.el7.x86_64

There were problems setting up VirtualBox. To re-start the set-up process, run
/sbin/vboxconfig
as root.
Verifying : VirtualBox-5.2-5.2.12_122591_el7-1.x86_64 1/2
Verifying : SDL-1.2.15-14.el7.x86_64 2/2

Installed:
VirtualBox-5.2.x86_64 0:5.2.12_122591_el7-1

Dependency Installed:
SDL.x86_64 0:1.2.15-14.el7

Complete!

##########

Leave a Reply

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