Centos7.5安装VirtualBox-5.2
1.查看自己的内核版本
[root@localhost /]# rpm -qa |grep kernel
kernel-tools-libs-3.10.0-862.6.3.el7.x86_64
kernel-ml-4.17.6-1.el7.elrepo.x86_64
kernel-tools-3.10.0-862.6.3.el7.x86_64
kernel-headers-3.10.0-862.6.3.el7.x86_64
2.查看yum中VirtualBox版本
[root@localhost /]# yum list | grep VirtualBox
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
VirtualBox-4.3.x86_64 4.3.40_110317_el7-1 virtualbox
VirtualBox-5.0.x86_64 5.0.40_115130_el7-1 virtualbox
VirtualBox-5.1.x86_64 5.1.38_122592_el7-1 virtualbox
VirtualBox-5.2.x86_64 5.2.16_123759_el7-1 virtualbox
最新版本为VirtualBox-5.2
3.导入epel安装源
yum install epel-release
4.添加VirtualBox安装源
# cd /etc/yum.repos.d/
# wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
5.安装相关依赖包
# yum update
# yum install binutils qt gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms
再次查看内核版本:
[root@localhost yum.repos.d]# rpm -qa |grep kernel
kernel-headers-3.10.0-862.11.6.el7.x86_64
kernel-ml-4.17.6-1.el7.elrepo.x86_64
kernel-tools-3.10.0-862.11.6.el7.x86_64
kernel-tools-libs-3.10.0-862.11.6.el7.x86_64
[root@localhost yum.repos.d]# uname -r
4.17.6-1.el7.elrepo.x86_64
发现kernel-headers,kernel-tools,kernel-tools-libs小版本升级了
6.安装VirtualBox
[root@localhost /]# yum install VirtualBox-5.2
7.启动
[root@localhost hongdada]# VirtualBox
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
available for the current kernel (4.17.6-1.el7.elrepo.x86_64) or it failed to
load. Please recompile the kernel module and install it by
sudo /sbin/vboxconfig
You will not be able to start VMs until this problem is fixed.
Qt FATAL: QXcbConnection: Could not connect to display
明显内核版本冲突
重建VirtualBox内核模块:
[root@localhost yum.repos.d]# /usr/lib/virtualbox/vboxdrv.sh setup
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
kernel-devel kernel-devel-4.17.6-1.el7.elrepo.x86_64
还是不行
安装低内核版本:
[root@localhost kernels]# yum install kernel-3.10.0-862.11.6.el7.x86_64
安装kernel-devel
yum install kernel-devel-3.10.0-862.11.6.el7.x86_64
再次查看内核版本:
[root@localhost yum.repos.d]# uname -r
4.17.6-1.el7.elrepo.x86_64
[root@localhost yum.repos.d]# rpm -qa |grep kernel
kernel-headers-3.10.0-862.11.6.el7.x86_64
kernel-ml-4.17.6-1.el7.elrepo.x86_64
kernel-tools-3.10.0-862.11.6.el7.x86_64
kernel-3.10.0-862.11.6.el7.x86_64
kernel-tools-libs-3.10.0-862.11.6.el7.x86_64
重启,选择低内核版本
8.低内核版本再次启动VirtualBox
查看内核版本,如果不一致,安装:
[root@localhost /]# yum install kernel-headers-$(uname -r) kernel-devel-$( uname -r) -y
再次重建VirtualBox内核模块
[root@localhost /]# /usr/lib/virtualbox/vboxdrv.sh setup
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
再次启动:
[root@localhost /]# VirtualBox
Qt FATAL: QXcbConnection: Could not connect to display
已放弃
[root@localhost /]# systemctl start vboxdrv.service
[root@localhost /]# systemctl status vboxdrv.service
● vboxdrv.service - VirtualBox Linux kernel module
Loaded: loaded (/usr/lib/virtualbox/vboxdrv.sh; enabled; vendor preset: disabled)
Active: active (exited) since 一 2018-09-03 15:13:15 CST; 55s ago
Process: 655 ExecStart=/usr/lib/virtualbox/vboxdrv.sh start (code=exited, status=0/SUCCESS)
Memory: 0B
9月 03 15:11:14 localhost.localdomain systemd[1]: Starting VirtualBox Linux kernel module...
9月 03 15:11:17 localhost.localdomain vboxdrv.sh[655]: vboxdrv.sh: Starting VirtualBox services.
9月 03 15:11:17 localhost.localdomain vboxdrv.sh[990]: Starting VirtualBox services.
9月 03 15:11:17 localhost.localdomain vboxdrv.sh[655]: vboxdrv.sh: Building VirtualBox kernel modules.
9月 03 15:13:15 localhost.localdomain systemd[1]: Started VirtualBox Linux kernel module.
终于好了
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)