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.

終於好了

參考:

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM