How To Install Virtualbox Guest Additions On CentOS via Command Line only
... finally this worked for me, should also work for anybody else trying to install VirtualBox Guest Additions on a CentOS (x86_64) virtual server in command line mode.
# yum update
# yum install dkms gcc make kernel-devel bzip2 binutils patch libgomp glibc-headers glibc-devel kernel-headers elfutils-libelf-devel
# mkdir -p /media/cdrom
# mount /dev/scd0 /media/cdrom
# sh /media/cdrom/VBoxLinuxAdditions.run
Note:
In CentOS 7 and higher the cdrom is at /dev/sr0
instead of /dev/scd0
.
When the process is complete, reboot the system. That's all.
@its_me's answer almost worked, but it failed building some kernel modules.
If it doesn't work for you, look at the messages.
In my case, one of them asked to look into /var/log/vboxadd-install.log
. There it said something about missing kernel sources and to provide the kernel source directory with e.g. KERN_DIR=/path/to/kernel/sources
.
Since kernel-devel
and sources at /usr/src/kernels/2.6.32-504.16.2.el6.x86_64
were already installed, I was confused, but called it with the requested environment variable
KERN_DIR=/usr/src/kernels/2.6.32-504.16.2.el6.x86_64 sh /media/cdrom/VBoxLinuxAdditions.run
Now it complained about missing header files and suggested to do
yum install kernel-devel-2.6.32-504.el6.x86_64
As you can see, this is a slightly different version, 504.16.2
vs just 504
. After installing the proper kernel-devel
package, building and then installing worked as expected.
So, running kernel and installed kernel sources (aka kernel-devel
) must match. You can verify this by looking at the running kernel with
uname -a
and the installed sources at
ls /usr/src/kernels
As a final conclusion, whatever happens, look at the messages and log files provided.
This is an old thread but came up in my search for a similar issue. In case anyone else runs into this, the following answer solved it for me:
http://www.if-not-true-then-false.com/2010/install-virtualbox-guest-additions-on-fedora-centos-red-hat-rhel/
Note* The URL says 2010 but the article was updated in 2013.