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
Update Required Packages
yum update gcc kernel-devel kernel-headers dkms make bzip2 perl wget
Remove All But The Latest Kernel
package-cleanup -y --oldkernels --count=1
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
Create the Mount Dir
Mount The ISO Image
mount -o loop,ro VBoxGuestAdditions_6.0.6.iso /media/VBoxGuestAdditions
Build The Tools
Problem & Solution
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.
- 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