unable to load vboxguest kernel module

vbox 安装增强功能失败一例

起因

vbox 从 6.9 升级到 7.1.6,Centos 7 虚拟机里的的共享文件夹设置失效了。尝识重新安装增强功能,报如下错:

[root@vbox cdrom]# ./VBoxLinuxAdditions.run
Verifying archive integrity...  100%   MD5 checksums are OK. All good.
Uncompressing VirtualBox 7.1.6 Guest Additions for Linux  100%
VirtualBox Guest Additions installer
Removing installed version 7.1.6 of VirtualBox Guest Additions...
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Setting up modules
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: Building the modules for kernel
3.10.0-1160.119.1.el7.x86_64.

VirtualBox Guest Additions: Look at /var/log/vboxadd-setup.log to find out what
went wrong
[root@vbox cdrom]# cat /var/log/vboxadd-setup.log
-bash: $'\346cat': command not found
[root@vbox cdrom]# cat /var/log/vboxadd-setup.log
Building the main Guest Additions 7.1.6 module for kernel 3.10.0-1160.119.1.el7.x86_64.
Error building the module.  Build output follows.
make V=1 CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C /lib/modules/3.10.0-1160.119.1.el7.x86_64/build M=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j1 modules
arch/x86/Makefile:169: *** CONFIG_RETPOLINE=y, but not supported by the compiler. Compiler update recommended..  Stop.
make: *** [vboxguest] Error 2
[root@vbox cdrom]#

 报错日志里有  “Compiler update recommended” 很明显是要升级编译工具。

安装高版本的编译工具

网上查了一下,看上去很 Easy,按下面这个命令就可以安装高版本的编译工具:

yum -y install centos-release-scl centos-release-scl-rh
yum -y install devtoolset-11-gcc devtoolset-11-gcc-c++ devtoolset-11-binutils

Centos 7 官方2024年6月以后就不再提供支持,所以更新 Centos 7 为国内 yum 源。

CentOs-Base.repo 的内容就不贴了,网上很多,照做基本都没有问题。

主要是 CentOS-SCLo-scl.repo 和 CentOS-SCLo-scl-rh.repo 这两个都要改,不要只改一个。

[root@vbox yum.repos.d]# cat CentOS-SCLo-scl.repo
# CentOS-SCLo-sclo.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/SCLo for more
# information

[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=http://mirrors.cloud.tencent.com/centos/7/sclo/$basearch/sclo/
#mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-sclo
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[root@vbox yum.repos.d]# cat CentOS-SCLo-scl-rh.repo
# CentOS-SCLo-rh.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/SCLo for more
# information

[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=http://mirrors.cloud.tencent.com/centos/7/sclo/$basearch/rh/
#mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-rh
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

修改完成后,重新安装devtoolset ,我这里用 11 的版本。

再次安装增强组件。 注意:安装前要执行  scl enable devtoolset-11 bash 使新版的gcc生效。

[root@vbox yum.repos.d]# gcc --version
gcc (GCC) 5.2.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@vbox yum.repos.d]# scl enable devtoolset-11 bash
[root@vbox yum.repos.d]# gcc --version
gcc (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@vbox yum.repos.d]#

安装成功

[root@vbox cdrom]# ./VBoxLinuxAdditions.run
Verifying archive integrity...  100%   MD5 checksums are OK. All good.
Uncompressing VirtualBox 7.1.6 Guest Additions for Linux  100%
VirtualBox Guest Additions installer
Removing installed version 7.1.6 of VirtualBox Guest Additions...
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Setting up modules
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: Building the modules for kernel
3.10.0-1160.119.1.el7.x86_64.
[root@vbox cdrom]#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

24K老游

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值