Virtual Box (1) Environment Preparations

1. About

Oracle VirtualBox is a virtual machine software produced by German InnoTek software company, and now it is developed by Oracle Corporation, which is a part of Oracle Corporation's xVM virtualization platform technology. It allows users to virtualize other x86 operating systems on 32-bit or 64-bit Windows, Solaris and Linux operating systems.

  • Wikipedia

Before proceeding to the next operation, please check whether your server supports nested virtualization, and pay attention to select the corresponding CPU architecture:

Bash
1
2
3
4
5
6
7
8
9
# Intel CPU
modprobe-kvm_intel

# AMD CPU
modprobe-kvm_amd

# enable kvm
modprobe-kvm

If kvm can be enabled normally, the above two commands will have no output. If the output CPU does not support kvm_intel or CPU does not support kvm_amd, you can give up and change to a cloud server manufacturer that supports nested virtualization.

2. Install Kernel-Header

Before installing VirtualBox, kernel-header needs to be installed first. However, the CentOS software source often does not have a matching version. Here is an example of the latest kernel-ml-5.19.12:

Open

Alibaba Cloud Software Sources
https://mirrors.aliyun.com/elrepo/kernel/el7/x86_64/RPMS/

Search for 5.19.12 and find the following files:

Text
1
2
3
4
5
6
kernel-ml-5.19.12-1.el7.elrepo.x86_64.rpm
kernel-ml-devel-5.19.12-1.el7.elrepo.x86_64.rpm
kernel-ml-headers-5.19.12-1.el7.elrepo.x86_64.rpm
kernel-ml-tools-5.19.12-1.el7.elrepo.x86_64.rpm
kernel-ml-tools-libs-5.19.12-1.el7.elrepo.x86_64.rpm
kernel-ml-tools-libs-devel-5.19.12-1.el7.elrepo.x86_64.rpm

Tip:
Generally speaking, you only need to install these few, and the other ones with doc, perf, and python do not need to be downloaded and installed.

Download and install:

Bash
1
2
3
4
cd ~
mkdir kernel-ml-5.19.12
cd kernel-ml-5.19.12
wget https://mirrors.aliyun.com/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-tools-libs-devel-5.19.12-1.el7.elrepo.x86_64.rpm https://mirrors. aliyun.com/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-tools-libs-5.19.12-1.el7.elrepo.x86_64.rpm https://mirrors.aliyun.com/elrepo/kernel/el7 /x86_64/RPMS/kernel-ml-tools-5.19.12-1.el7.elrepo.x86_64.rpm https://mirrors.aliyun.com/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-headers- 5.19.12-1.el7.elrepo.x86_64.rpm https://mirrors.aliyun.com/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-5.19.12-1.el7.elrepo.x86_64.rpm https://mirrors.aliyun.com/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-devel-5.19.12-1.el7.elrepo.x86_64.rpm

Install:

Bash
1
rpm -ivh *.rpm --force

Execute if an error is reported:

Bash
1
rpm -ivh *.rpm --force --nodeps

Uninstall the old version of Kernel related packages:

Bash
1
2
3
4
5
6
7
8
9
10
11
12
# If the old version is Kernel-4.x
rpm -e `rpm -qa|grep kernel-ml-4` --nodeps
rpm -e `rpm -qa|grep kernel-ml-tools-4` --nodeps
rpm -e `rpm -qa|grep kernel-ml-devel-4` --nodeps
rpm -e `rpm -qa|grep kernel-ml-headers-4` --nodeps

#If the old version is Kernel-3.x
rpm -e `rpm -qa|grep kernel-ml-3` --nodeps
rpm -e `rpm -qa|grep kernel-ml-tools-3` --nodeps
rpm -e `rpm -qa|grep kernel-ml-devel-3` --nodeps
rpm -e `rpm -qa|grep kernel-ml-headers-3` --nodeps

At this point, the default boot kernel will be up to date. Just in case, if it is not set successfully, it may fail to start, or you need to reset it. Take CentOS 7 as an example:

Bash
1
2
3
4
5
6
# First check all startup items
cat /boot/grub2/grub.cfg | grep -v rescue | grep ^menuentry

# Set the default kernel again
grub2-set-default 'CentOS Linux (5.19.12-1.el7.elrepo.x86_64) 7 (Core)'

3. Install Virtual-Box

Note: VirtualBox requires a higher version of GCC, refer to the article on this site:

CentOS7 compile and upgrade GCC
https://blog.tsinbei.com/archives/860/

Take CentOS as an example, execute:

Bash
1
2
curl http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo -o /etc/yum.repos.d/virtualbox.repo
yum install VirtualBox-6.1

The installation is successful, execute

Bash
1
/sbin/rcvboxdrv setup

If there are no errors, the installation is complete.

Virtual Box (1) Environment Preparations

https://blog.tsinbei.com/en/archives/663/

Author
Hsukqi Lee
Posted on

2022-12-13

Edited on

2022-12-13

Licensed under

CC BY-NC-ND 4.0

Comments

Name
Mail
Site
None yet