Install VirtualBox on CentOS 7 on VirtualBox (mac + vagrant)

When I tried to run kubernetes (minikube) on CentOS7 on VirtualBox (mac + vagrant), I had to install VirtualBox on CentOS7.

I will describe the procedure at that time.

Add yum repository to CentOS

Refer to the official website page below and add the virtualBox yum repository to CentOS.

$ sudo wget https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo -O /etc/yum.repos.d/virtualbox.repo

Import the public key for tampering check into CentOS

On the official website page

Note that importing the key is not necessary for yum users (Oracle Linux/Fedora/RHEL/CentOS) when using one of the virtualbox.repo files from below as yum downloads and imports the public key automatically!

(Google translation) yum automatically downloads and imports the public key, so if you use any of the virtualbox.repo files from below, give the key to yum users (Oracle Linux / Fedora / RHEL / CentOS) No need to import.

Is written, but that is not the case.

Because later to see which version can be installed

yum list |grep Virtual

This is because the public key for tampering check must be imported into CentOS in advance. So you will eventually need to import this public key. (Of course, this is not the case if you know the installable version in advance.)

Import the public key as described on the official website.

wget https://www.virtualbox.org/download/oracle_vbox.asc
sudo rpm --import oracle_vbox.asc

Install VirtualBox

Check the version of VirtualBox that can be installed.

$ yum list |grep Virtual

VirtualBox-4.3.x86_64                       4.3.40_110317_el7-1        virtualbox
VirtualBox-5.0.x86_64                       5.0.40_115130_el7-1        virtualbox
VirtualBox-5.1.x86_64                       5.1.38_122592_el7-1        virtualbox
VirtualBox-5.2.x86_64                       5.2.38_136252_el7-1        virtualbox
VirtualBox-6.0.x86_64                       6.0.18_136238_el7-1        virtualbox
VirtualBox-6.1.x86_64                       6.1.4_136177_el7-1         virtualbox

Install the latest version.

sudo yum install VirtualBox-6.1.x86_64

Install kernel module

Let's check if virtualbox works.

$ virtualbox

WARNING: The vboxdrv kernel module is not loaded. Either there is no module
         available for the current kernel (3.10.0-957.12.2.el7.x86_64) or it failed to
         load. Please recompile the kernel module and install it by

           sudo /sbin/vboxconfig

         You will not be able to start VMs until this problem is fixed.
Qt FATAL: QXcbConnection: Could not connect to display 
Aborted

I got an error. The error message says to execute sudo / sbin / vboxconfig, so let's execute it obediently.

$ sudo /sbin/vboxconfig

vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
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-957.12.2.el7.x86_64

An error has occurred. Looking at the error message,

Please install the gcc make perl packages from your distribution.

Since it is said that it will be installed obediently.

$ sudo yum install gcc make perl

In addition, the error message also contained the following:

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-957.12.2.el7.x86_64

Since there is no kernel-devel, install it obediently as well.

$ sudo yum install kernel-devel

Restart CentOS for the settings to take effect and try again. (Reboot may not be necessary)

$ sudo /sbin/vboxconfig

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-957.12.2.el7.x86_64

that? The same error because there is no "kernel-devel".

I wondered if SELinux was involved, so I tried disabling SELinux, but the situation did not change.

After a lot of research, it seemed that the cause was that the kernel-devel corresponding to the kernel version of CentOS was not installed.

$ sudo yum install kernel-devel

If you do, the latest version of kenel-devel will be installed. The latest version of kenel-devel is inconsistent with the version of the CentOS kernel, so an error occurred.

See the explanation below for details. It will be very helpful. Follow the steps described here to install kernel-devel, which is consistent with your CentOS kernel version.  https://qiita.com/metheglin/items/60261f474ccdfb467574

Then try again.

$ sudo /sbin/vboxconfig

vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.

It finally worked!

bonus

This time, I was running CentOS7 on a Mac VirtualBox and trying to run VirtualBox on that CentOS. As a result, I tried to run kubernetes (minikube) on CentOS.

Running more VMs in these VMs is called "Nested VM".

However, this nested VM was not available on the Mac VirutualBox. It seems that it only supports AMD CPUs, and it can not be used with Mac Intel CPUs. It was a pity that I did my best like this article.

I gave up running kubernetes on CentOS 7 on VirtualBox and decided to run it on mac (end).

Recommended Posts

Install VirtualBox on CentOS 7 on VirtualBox (mac + vagrant)
Steps to install VirtualBox on CentOS
Install Tensorflow on Mac
Install Faiss on CentOS 7
Install pyenv on mac
Install numba on CentOS 7.2
Install Ansible on Mac
Install Python on Mac
Install mecab-python on CentOS
Install Python 2.7.3 on CentOS 5.4
Install Python 3.4 on Mac
Installation on CentOS8 VirtualBox
Install Caffe on Mac
Install mecab on mac
Install awscli on centos7
Install Chainer on CentOS 6.7
Install mecab-python on Mac
Install pygame on python3.4 on mac
Install CentOS7 VirtualBox Guest Additons
Install ImageMagick-6.2.x series on CentOS7.7
Install module on Anaconda (Mac)
Install OpenPose on mac (Catalina)
Install numba on your Mac
Install pandas 0.14 on python3.4 [on Mac]
Install Chrome on CentOS 7 series
Install pillow on Mac OSX 10.9
[Mac] Tips: Install pyquery on Mac [pyquery]
Install Python 3.8 on CentOS 8 (AppStream)
Steps to install MySQL 8.0 on CentOS 8.1
Install anaconda on Mac → Add Library
raspberry pi 4 centos7 install on docker
How to install mysql-connector-python on mac
Steps to install matplotlib on Mac
Install Python 3.7 Anaconda on MAC, but Python 2
Install Scipy on Mac OS Sierra
Install python3 on Mac (El Capitan)
Install java (Oracle JDK14) on CentOS7
[Linux] I installed CentOS on VirtualBox
How to install OpenCV on Mac
How to install TensorFlow on CentOS 7
Install pip on CentOS7. Also iPython.
Install mitmproxy on Mac OS X
Connect to centos6 on virtualbox with ssh connection from Mac
Install Python on CentOS using Pyenv
How to install Maven on CentOS
Steps to install python3 on mac
Study Note 9_Install Jenkins on CentOS7
Install Python on CentOS using pyenv
Install pgmagick on Mac OS X 10.9
How to install drobertadams / toggl-cli on Mac
Install Mecab on Linux (CentOS) with brew
How to install Apache (httpd) on CentOS7
How to install Eclipse GlassFish 5.1.0 on CentOS 7
Install anaconda on a new Mac anyway
How to install Apache (httpd) on CentOS8
Install PostgreSQL from source code on CentOS
Install pyenv and rbenv on CentOS system-wide
CentOS8 --Install --Django
python on mac
CentOS8 --Install --Python3
[Ansible] Install dnf on Centos7 with Python3 interpreter