Centos7.5安装VirtualBox-5.2

田佐
2023-12-01
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.

终于好了

参考:

https://www.cnblogs.com/harry-h/p/6405433.html

转载于:https://www.cnblogs.com/hongdada/p/9578849.html

 类似资料: