CentOS 7 Guest additions problem

Discussions about using Linux guests in VirtualBox.
Post Reply
alwinlau0824
Posts: 5
Joined: 3. Oct 2020, 03:22

CentOS 7 Guest additions problem

Post by alwinlau0824 »

I have a problem with my setup on Guest additions
It showed:

Verifying archive integrity... All good.
Uncompressing VirtualBox 6.1.14 Guest Additions for Linux........
VirtualBox Guest Additions installer
Removing installed version 6.1.14 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
5.8.14-1.el7.elrepo.x86_64. Please install them and execute
/sbin/rcvboxadd setup
libsemanage.semanage_read_policydb: Could not open kernel policy /etc/selinux/targeted/active/policy.kern for reading. (No such file or directory).
OSError: No such file or directory
modprobe vboxguest failed
The log file /var/log/vboxadd-setup.log may contain further information.
Press Return to close this window...

I have updated to the latest version of kernel and reinstall the kernel policy by following this https://www.youtube.com/watch?v=YO3Vp8dZIyo
And rebooted, but it seems doesn't work.
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: CentOS 7 Guest additions problem

Post by fth0 »

alwinlau0824 wrote:VirtualBox Guest Additions: Kernel headers not found for target kernel
5.8.14-1.el7.elrepo.x86_64. Please install them and execute
/sbin/rcvboxadd setup
And did you also install the kernel headers matching your updated kernel (as requested)?
multiOS
Volunteer
Posts: 832
Joined: 14. Sep 2019, 16:51
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: WIN11,10, 7, Linux (various)
Location: United Kingdom

Re: CentOS 7 Guest additions problem

Post by multiOS »

This is the Guest Additions procedure I followed when I last did a test install of CentOS 8:

Note: All of the Terminal Commands required Root privileges (sudo)

1. Enable the EPEL repository on the CentOS guest operating system to install some required packages needed for the installation process

# yum -y install epel-release

2. Update each package on the guest system including the kernel to the latest version that is both available and resolvable

# yum -y update

Reboot the system to complete the installation process and start using the new kernel.

3. Install the kernel headers, developer tools and other related packages required for installing the Guest Additions from source.

# yum install make gcc kernel-headers kernel-devel perl dkms bzip2 [Note: dkms shouldn’t be necessary for installing VirtualBox Guest Additions but most (all?) linux distributions still seem to specify it as a requirement.)

4. Set the KERN-DIR environment variable to kernel source code directory (/usr/src/kernels/$(uname -r)) and export it:

# export KERN-DIR=/usr/src/kernels/$(uname -r)

5. Mount the Guest Additions ISO:

- use the normal GUI installer, which should auto-start; or
- install via Terminal:

# mount -r /dev/cdrom /media
# cd /media/
# .VBoxLinuxAdditions.run

6. Power Off the guest

Make the following changes to the VirtualBox Settings if not already done:

- Enable bi-directional shared clipboard and drag’n’drop functions in the General => Advanced Tab

7. Reboot and check that Guest Additions features work. Don’t forget to unmount the Guest Additions ISO.

I documented this for my own use at the time, as the process was substantialy different to other distributions. It's still working, though largely unused!
alwinlau0824
Posts: 5
Joined: 3. Oct 2020, 03:22

Re: CentOS 7 Guest additions problem

Post by alwinlau0824 »

My Kernel header show:
[root@localhost alwinlau0824]# yum install kernel-headers
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.hkt.cc
* elrepo: mirror-hk.koddos.net
* epel: fedora.ipserverone.com
* extras: mirror.xtom.com.hk
* updates: mirror.xtom.com.hk
Package kernel-headers-3.10.0-1127.19.1.el7.x86_64 already installed and latest version
Nothing to do
________________________________
My Selinux policy show:
[root@localhost alwinlau0824]# yum install selinux-policy
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.hkt.cc
* elrepo: mirror-hk.koddos.net
* epel: fedora.ipserverone.com
* extras: mirror.xtom.com.hk
* updates: mirror.xtom.com.hk
Package selinux-policy-3.13.1-266.el7_8.1.noarch already installed and latest version
Nothing to do
I have reinstalled both already.

It still doesn't work
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: CentOS 7 Guest additions problem

Post by fth0 »

I don't know much about CentOS 7, except that it originally comes with kernel 3.10. For some reason unknown to me, VirtualBox is thinking that you're using kernel 5.8. What's the output of uname -a ?
SirZooro
Posts: 3
Joined: 20. Dec 2018, 20:28

Re: CentOS 7 Guest additions problem

Post by SirZooro »

I have the same problem.

Code: Select all

uname -a
Linux localhost.localdomain 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Update: here are versions of kernel and headers:

Code: Select all

rpm -q kernel kernel-headers
kernel-3.10.0-1127.19.1.el7.x86_64
kernel-headers-3.10.0-1127.19.1.el7.x86_64
multiOS
Volunteer
Posts: 832
Joined: 14. Sep 2019, 16:51
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: WIN11,10, 7, Linux (various)
Location: United Kingdom

Re: CentOS 7 Guest additions problem

Post by multiOS »

Have you tried the method described on the CentOS website here: https://wiki.centos.org/HowTos/Virtuali ... entOSguest ? Essentially, it's the same as I used and described above for CentOS 8, but without some detail.

If that didn't/doesn't work it would be helpful to know the details of any errors messages received.
SirZooro
Posts: 3
Joined: 20. Dec 2018, 20:28

Re: CentOS 7 Guest additions problem

Post by SirZooro »

Thanks for the link. It turned out that I had to install kernel-devel, after doing this I was able to successfully compile guest additions. BTW, I also installed dkms, but it probably is not needed for the build.

I installed CentOS 7 few times in the past, and usually it was enough to install development tools group and kernel-headers to compile guest additions. Looks that something has changed recently - maybe kernel-devel is no longer installed as a dependency automatically, or guest additions now needs something from that package. Anyway, message which they print (Kernel headers not found for target kernel <kernel version>) is misleading, usually error like this meant that proper version of kernel-headers package is missing.
multiOS
Volunteer
Posts: 832
Joined: 14. Sep 2019, 16:51
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: WIN11,10, 7, Linux (various)
Location: United Kingdom

Re: CentOS 7 Guest additions problem

Post by multiOS »

Thanks for the feedback. Glad you're up and running.

The dkms isn't an 'essential' dependency, but all linux distributions still seem to recommend it. The CentOS page is the only one I've ever seen explaining giving reason, i.e. installing dkms means you shouldn't have to manually re-install the Guest Additions after each Linux Kernel 'upgrade'. Not that frequent with CentOS in my experience, but more of an issue with some others, especially the rolling releases.
Post Reply