How to Install VirtualBox Guest Additions in Linux CentOS 8 running in a VirtualBox via command line

Posted on

Introduction

This article will show how to install VirtualBox Guest Additions in Linux CentOS 8 via command line. Actually, there is a main purpose for installing VirtualBox Guest Additions in any virtual server. It will enhance the ability of the virtual server running in VirtualBox application. In order to install VirtualBox Guest Additions, there are several parts to complete the installation. Those parts are mounting the ISO image file in VirtualBox application and also running the VirtualBox Guest Additions installer.

 

Mounting ISO Image File in VirtualBox Application

So, the following are steps for installing VirtualBox Guest Additions in Linux CentOS 8 virtual server :

1. First of all, download the VirtualBox Guest Additions installer file. The file is available in this link where it is actually an official download page of VirtualBox file installer. Another one also exist in this link which is an index page for selecting VirtualBox file installer. Select the most suitable one from the download page.

2. Actually, the result from downloading the file is an ISO image file. In this context, for an example, the file name is VBoxGuestAdditions_6.1.16.iso. Rename it to VBoxGuestAdditions.iso to make it simple. So, in the next step, just add the downloaded ISO image file to the VirtualBox application. In order to add the ISO image file to the VirtualBox application, just read the related article. It is an article with the title of ‘How to Add ISO Image File in the VirtualBox Application’ in this link.

4. After that, just add the file or mount it in the virtual server available in the VirtualBox application. Read the article exist with the title of ‘How to Mount ISO Image File in Linux CentOS 8 Running in VirtualBox’ in this link.

5. Next step, start the virtual server in the VirtualBox application as in the following image :

How to Install VirtualBox Guest Additions in Linux CentOS 8 running in a VirtualBox via command line
How to Install VirtualBox Guest Additions in Linux CentOS 8 running in a VirtualBox via command line

5. If the start process of the virtual server of CentOS 8 in VirtualBox application is a success, the following image will appear  :

How to Install VirtualBox Guest Additions in Linux CentOS 8 running in a VirtualBox via command line
How to Install VirtualBox Guest Additions in Linux CentOS 8 running in a VirtualBox via command line

Mounting ISO Image File in Linux CentOS 8 Virtual Server

After finishing on adding the ISO image file, the following steps are important in order to install VirtualBox Guest Additions :

1. First of all, just login to the virtual server. Either directly login via VirtualBox application or access it remotely. The following article with the title of ‘How to Remote CentOS Virtual Server running in a VirtualBox with a NAT Network using SSH’ in this link inform how to remotely access the virtual server via SSH.

2. After successfully logging in, execute the following series of command. The first one is to create a folder for mounting the virtual CD/DVD-ROM as follows :

cd  /dev
mkdir cdrom

The following is an image showing the mount process :

How to Install VirtualBox Guest Additions in Linux CentOS 8 running in a VirtualBox via command line
How to Install VirtualBox Guest Additions in Linux CentOS 8 running in a VirtualBox via command line

3. Last but not least, check the content of the mounted folder as in the image below :

How to Install VirtualBox Guest Additions in Linux CentOS 8 running in a VirtualBox via command line
How to Install VirtualBox Guest Additions in Linux CentOS 8 running in a VirtualBox via command line

As in the above display, the output of the command is list of files available in the mounted CD/DVD-ROM. So, the installation process can begin by executing the file ‘VBoxLinuxAdditions.run’. But actually, there is an additional process before doing on that. The additional process will be available in the next part which is the actual installation of VirtualBox Guest Additions in Linux CentOS 8.

 

Installing VirtualBox Guest Additions in Linux CentOS 8 Virtual Server

Actually, there are several steps which is actually prerequisites or requirements before installing VirtualBox Guest Additions. This article is referring another article with the title of ‘How to Install VirtualBox Guest Additions on CentOS 8’ in this link. The following are the actual steps :

1. First of all, install the epel-release repository by executing the following command :

[admin@10 cdrom]$ sudo dnf install epel-release
Last metadata expiration check: 2:33:34 ago on Thu 31 Dec 2020 03:09:25 AM EST.
Dependencies resolved.
============================================================================================================================================================================================================================================
 Package                                                      Architecture                                           Version                                                   Repository                                              Size
============================================================================================================================================================================================================================================
Installing:
 epel-release                                                 noarch                                                 8-8.el8                                                   extras                                                  23 k

Transaction Summary
============================================================================================================================================================================================================================================
Install  1 Package

Total download size: 23 k
Installed size: 32 k
Is this ok [y/N]: y
Downloading Packages:
epel-release-8-8.el8.noarch.rpm                                                                                                                                                                              13 kB/s |  23 kB     00:01
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                       7.8 kB/s |  23 kB     00:02
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                    1/1
  Installing       : epel-release-8-8.el8.noarch                                                                                                                                                                                        1/1
  Running scriptlet: epel-release-8-8.el8.noarch                                                                                                                                                                                        1/1
  Verifying        : epel-release-8-8.el8.noarch                                                                                                                                                                                        1/1

Installed:
  epel-release-8-8.el8.noarch

Complete!
[admin@10 cdrom]$

The installation of the epel-release repository exist as in the following image :

How to Install VirtualBox Guest Additions in Linux CentOS 8 running in a VirtualBox via command line
How to Install VirtualBox Guest Additions in Linux CentOS 8 running in a VirtualBox via command line

2. If the above command execution is a success, check whether the epel-release repository is available by executing the command below :

[admin@10 cdrom]$ sudo dnf list installed | grep epel-release
epel-release.noarch                  8-8.el8                               @extras
[admin@10 cdrom]$

3. So, the previous step is an important step. By installing the epel-release, the installation of the following package will be possible. In this next step, the main purpose is to install several additional packages. It is the kernel-headers and another tools. It is very important for installing VirtualBox Guest Additions. Just execute the following command :

[admin@10 cdrom]$ sudo dnf install gcc make perl kernel-devel kernel-headers bzip2 dkms
Extra Packages for Enterprise Linux Modular 8 - x86_64 100 kB/s | 528 kB 00:05
Extra Packages for Enterprise Linux 8 - x86_64 884 kB/s | 8.7 MB 00:10
Last metadata expiration check: 0:00:01 ago on Thu 31 Dec 2020 05:45:00 AM EST.
Package bzip2-1.0.6-26.el8.x86_64 is already installed.
Dependencies resolved.
============================================================================================================================================================================================================================================
Package Architecture Version Repository Size
============================================================================================================================================================================================================================================
Installing:
dkms noarch 2.8.4-1.el8 epel 81 k
gcc x86_64 8.3.1-5.1.el8 AppStream 23 M
kernel-devel x86_64 4.18.0-240.1.1.el8_3 BaseOS 17 M
kernel-headers x86_64 4.18.0-240.1.1.el8_3 BaseOS 5.5 M
make x86_64 1:4.2.1-10.el8 BaseOS 498 k
perl x86_64 4:5.26.3-416.el8 AppStream 72 k
Upgrading:
elfutils-libelf x86_64 0.180-1.el8 BaseOS 215 k
elfutils-libs x86_64 0.180-1.el8 BaseOS 293 k
glibc x86_64 2.28-127.el8 BaseOS 3.6 M
glibc-all-langpacks x86_64 2.28-127.el8 BaseOS 25 M
glibc-common x86_64 2.28-127.el8 ...
AppStream 298 k
perl-Mozilla-CA noarch 20160104-7.module_el8.3.0+416+dee7bcef AppStream 15 k
perl-TermReadKey x86_64 2.37-7.el8 AppStream 40 k
Enabling module streams:
perl 5.26
perl-IO-Socket-SSL 2.066
perl-libwww-perl 6.34

Transaction Summary
============================================================================================================================================================================================================================================
Install 169 Packages
Upgrade 8 Packages

Total download size: 112 M
Is this ok [y/N]: y
Downloading Packages:
(1/177): annobin-9.23-1.el8.x86_64.rpm 157 kB/s | 104 kB 00:00
(2/177): dwz-0.12-9.el8.x86_64.rpm 134 kB/s | 109 kB 00:00
...
(176/177): glibc-common-2.28-127.el8.x86_64.rpm 443 kB/s | 1.3 MB 00:03
(177/177): glibc-all-langpacks-2.28-127.el8.x86_64.rpm 766 kB/s | 25 MB 00:33
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.0 MB/s | 112 MB 01:48
warning: /var/cache/dnf/epel-6519ee669354a484/packages/dkms-2.8.4-1.el8.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 2f86d6a1: NOKEY
Extra Packages for Enterprise Linux 8 - x86_64 1.6 MB/s | 1.6 kB 00:00
Importing GPG key 0x2F86D6A1:
Userid : "Fedora EPEL (8) <epel@fedoraproject.org>"
Fingerprint: 94E2 79EB 8D8F 25B2 1810 ADF1 21EA 45AB 2F86 D6A1
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Upgrading : glibc-all-langpacks-2.28-127.el8.x86_64 1/185
Upgrading : glibc-common-2.28-127.el8.x86_64 2/185
Running scriptlet: glibc-2.28-127.el8.x86_64 3/185
Upgrading : glibc-2.28-127.el8.x86_64 3/185
Running scriptlet: glibc-2.28-127.el8.x86_64 3/185
Installing : perl-Exporter-5.72-396.el8.noarch
... 185/185
Running scriptlet: libgcc-8.3.1-5.el8.0.2.x86_64 185/185
Running scriptlet: glibc-common-2.28-127.el8.x86_64 185/185
Verifying : annobin-9.23-1.el8.x86_64 1/185
Verifying : cpp-8.3.1-5.1.el8.x86_64 2/185
Verifying : dwz-0.12-9.el8.x86_64
... 184/185
Verifying : zlib-1.2.11-13.el8.x86_64 185/185

Upgraded:
elfutils-libelf-0.180-1.el8.x86_64 elfutils-libs-0.180-1.el8.x86_64 glibc-2.28-127.el8.x86_64 glibc-all-langpacks-2.28-127.el8.x86_64 glibc-common-2.28-127.el8.x86_64 libgcc-8.3.1-5.1.el8.x86_64 libgomp-8.3.1-5.1.el8.x86_64
zlib-1.2.11-16.el8_2.x86_64

Installed:
annobin-9.23-1.el8.x86_64 cpp-8.3.1-5.1.el8.x86_64 dkms-2.8.4-1.el8.noarch
dwz-0.12-9.el8.x86_64 efi-srpm-macros-3-2.el8.noarch
...
systemtap-sdt-devel-4.3-4.el8.x86_64
zlib-devel-1.2.11-16.el8_2.x86_64

Complete!
[admin@10 cdrom]$

4. Next step, check the available version of the kernel-devel whether it is suitable with the current kernel version running in the operating system. Just run the following command :

[admin@10 cdrom]$ sudo dnf list installed | grep kernel-devel
[sudo] password for admin:
kernel-devel.x86_64                  4.18.0-240.1.1.el8_3                   @BaseOS
[admin@10 cdrom]$

So, the kernel-devel version is ‘4.18.0-240.1.1’.

[admin@10 cdrom]$ uname -r
4.18.0-193.el8.x86_64
[admin@10 cdrom]$

5. Unfortunately, the kernel version of the current running operating system is ‘4.18.0-193’. So, execute the following command to update the current kernel version :

[admin@10 cdrom]$ sudo dnf update kernel-*
Last metadata expiration check: 0:11:50 ago on Thu 31 Dec 2020 05:45:00 AM EST.
Dependencies resolved.
============================================================================================================================================================================================================================================
 Package                                                     Architecture                                     Version                                                                Repository                                        Size
============================================================================================================================================================================================================================================
Installing:
 kernel-core                                                 x86_64                                           4.18.0-240.1.1.el8_3                                                   BaseOS                                            30 M
 kernel-modules                                              x86_64                                           4.18.0-240.1.1.el8_3                                                   BaseOS                                            26 M
Upgrading:
 kernel-tools                                                x86_64                                           4.18.0-240.1.1.el8_3                                                   BaseOS                                           4.5 M
 kernel-tools-libs                                           x86_64                                           4.18.0-240.1.1.el8_3                                                   BaseOS                                           4.3 M
 linux-firmware                                              noarch                                           20200619-99.git3890db36.el8                                            BaseOS                                           101 M

Transaction Summary
============================================================================================================================================================================================================================================
Install  2 Packages
Upgrade  3 Packages

Total download size: 166 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): kernel-tools-4.18.0-240.1.1.el8_3.x86_64.rpm                                                                                                                                                         347 kB/s | 4.5 MB     00:13
(2/5): kernel-tools-libs-4.18.0-240.1.1.el8_3.x86_64.rpm                                                                                                                                                    329 kB/s | 4.3 MB     00:13
(3/5): kernel-modules-4.18.0-240.1.1.el8_3.x86_64.rpm                                                                                                                                                       445 kB/s |  26 MB     00:58
(4/5): kernel-core-4.18.0-240.1.1.el8_3.x86_64.rpm                                                                                                                                                          417 kB/s |  30 MB     01:14
(5/5): linux-firmware-20200619-99.git3890db36.el8.noarch.rpm                                                                                                                                                868 kB/s | 101 MB     01:59
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                       1.1 MB/s | 166 MB     02:26
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                    1/1
  Running scriptlet: linux-firmware-20200619-99.git3890db36.el8.noarch                                                                                                                                                                  1/1
...
  Cleanup          : kernel-tools-4.18.0-193.el8.x86_64                                                                                                                                                                                 6/8
  Cleanup          : linux-firmware-20191202-97.gite8a0f4c9.el8.noarch                                                                                                                                                                  7/8
  Cleanup          : kernel-tools-libs-4.18.0-193.el8.x86_64                                                                                                                                                                            8/8
  Running scriptlet: kernel-tools-libs-4.18.0-193.el8.x86_64                                                                                                                                                                            8/8
  Running scriptlet: kernel-core-4.18.0-240.1.1.el8_3.x86_64                                                                                                                                                                            8/8
dkms: running auto installation service for kernel 4.18.0-240.1.1.el8_3.x86_64
 Done.

  Running scriptlet: kernel-tools-libs-4.18.0-193.el8.x86_64                                                                                                                                                                            8/8
  Verifying        : kernel-core-4.18.0-240.1.1.el8_3.x86_64                                                                                                                                                                            1/8
...
  Verifying        : linux-firmware-20191202-97.gite8a0f4c9.el8.noarch                                                                                                                                                                  8/8

Upgraded:
  kernel-tools-4.18.0-240.1.1.el8_3.x86_64                                 kernel-tools-libs-4.18.0-240.1.1.el8_3.x86_64                                 linux-firmware-20200619-99.git3890db36.el8.noarch

Installed:
  kernel-core-4.18.0-240.1.1.el8_3.x86_64                                                                             kernel-modules-4.18.0-240.1.1.el8_3.x86_64

Complete!
[admin@10 cdrom]$

6. If the update process of the current running kernel is a success, do not forget to reboot. Also select the update version of the operating system. It is the operating system with the latest kernel as in the following image :

How to Install VirtualBox Guest Additions in Linux CentOS 8 running in a VirtualBox via command line
How to Install VirtualBox Guest Additions in Linux CentOS 8 running in a VirtualBox via command line

7. Soon after the reboot and logging in is finish do not forget to recheck. It is to check the version again by typing the following command as in the previous step :

[admin@10 cdrom]$ uname -r
4.18.0-240.1.1.el8_3.x86_64
[admin@10 cdrom]$

7. Fortunately, the current version of the kernel running in the operating system is now exactly the same with the kernel-devel version. Just proceed with the next step which is the final step. It is installing the VirtualBox Guest Addition. It is available in the mounted image. Just execute the following command :

[admin@10 cdrom]$ sudo ./VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 6.1.16 Guest Additions for Linux........
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
modules. This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup
VirtualBox Guest Additions: or
VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel
4.18.0-240.1.1.el8_3.x86_64.
[admin@10 cdrom]$

One thought on “How to Install VirtualBox Guest Additions in Linux CentOS 8 running in a VirtualBox via command line

Leave a Reply