This document lists all the steps needed to successfully build the VirtualBox Tools in Centos 7 without access to the graphical interface and the need to install X server. This is very handy when building a local (Vagrant) based testing instances.

Install Required Packages

yum install gcc kernel-devel kernel-headers dkms make bzip2 perl wget

or

Update Required Packages

yum update gcc kernel-devel kernel-headers dkms make bzip2 perl wget

reboot

Remove All But The Latest Kernel

package-cleanup -y --oldkernels --count=1

reboot

Add KERN_DIR Environment Variable

KERN_DIR=/usr/src/kernels/3.10.0-693.17.1.el7-x86_64/build

export KERN_DIR

Download The Tools

wget https://download.virtualbox.org/virtualbox/6.0.6/VBoxGuestAdditions_6.0.6.iso

Create the Mount Dir

mkdir /media/VBoxGuestAdditions

Mount The ISO Image

mount -o loop,ro VBoxGuestAdditions_6.0.6.iso /media/VBoxGuestAdditions

Build The Tools

sh /media/VBoxGuestAdditions/VBoxLinuxAdditions.run

reboot

Cleanup

rm VBoxGuestAdditions_4.3.8.iso

umount /media/VBoxGuestAdditions

rm /media/VBoxGuestAdditions

Problem & Solution

Problem

If running the VBoxGuestAdditions installation process on Centos 7 fails with this or similar error then follow the 3 simple rules on the bottom of this page to fix it.

[root@localhost ~]# sh /media/VBoxGuestAdditions/VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 6.0.6 Guest Additions for Linux........
VirtualBox Guest Additions installer
Removing installed version 6.0.6 of VirtualBox Guest Additions...
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 <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Kernel headers not found for target kernel
3.10.0-957.5.1.el7.x86_64. Please install them and execute
  /sbin/rcvboxadd setup
modprobe vboxguest failed
The log file /var/log/vboxadd-setup.log may contain further information.

Solution

  • only 1 kernel installed and in use
  • full system upgrade prior to the installation process
  • most likely caused by yum update gone bad and kernel to kernel-headers mismatch

Ansible Automation

TBD


Published

Category

Linux

Tags

Contact