1, 下载VitrualBox.repo文件,
wget https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo
mv virtualbox.repo /etc/yum.repos.d/
2,安装VitrualBox
[root@~]# dnf update
[root@~]# dnf clean all
[root@~]# dnf makecache
[root@~]# dnf search virtualbox
Last metadata expiration check: 0:00:20 ago on Thu 16 Sep 2021 08:29:35 PM CST.
=============================================================== Name & Summary Matched: virtualbox =
VirtualBox-5.2.x86_64 : Oracle VM VirtualBox
VirtualBox-6.0.x86_64 : Oracle VM VirtualBox
VirtualBox-6.1.x86_64 : Oracle VM VirtualBox
[root@~]# dnf install VirtualBox-6.1.x86_64
3,运行VitrualBox
[root@~]# VirtualBox
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
available for the current kernel (4.18.0-305.17.1.el8_4.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 WARNING: could not connect to display
Qt FATAL: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
Aborted (core dumped)
如上,表示运行不成功,需要运行/sbin/vboxconfig检查依赖环境
[root@~]# sudo /sbin/vboxconfig
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 gcc make perl packages from your distribution.
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.18.0-305.17.1.el8_4.x86_64
This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.
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.18.0-305.17.1.el8_4.x86_64
There were problems setting up VirtualBox. To re-start the set-up process, run
/sbin/vboxconfig
as root. If your system is using EFI Secure Boot you may need to sign the
kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load
them. Please see your Linux system's documentation for more information.
提示缺少 gcc, make, perl,kernel-devel
[root@~]# dnf install gcc make perl kernel-devel
[root@~]# /sbin/vboxconfig
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: failed: Look at /var/log/vbox-setup.log to find out what went wrong.
There were problems setting up VirtualBox. To re-start the set-up process, run
/sbin/vboxconfig
as root. If your system is using EFI Secure Boot you may need to sign the
kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load
them. Please see your Linux system's documentation for more information.
还是运行失败,提示到/var/log/vbox-setup.log文件中查看失败原因
[root@~]# cat /var/log/vbox-setup.log
Building the main VirtualBox module.
Error building the module:
make V=1 CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C /lib/modules/4.18.0-305.17.1.el8_4.x86_64/build M=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j8 modules
make[1]: warning: -jN forced in submake: disabling jobserver mode.
Makefile:984: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel". Stop.
make: *** [/tmp/vbox.0/Makefile-footer.gmk:117: vboxdrv] Error 2
提示需要install libelf-dev, libelf-devel or elfutils-libelf-devel 3个依赖中的一个,挨个尝试,只有最后一个可以安装
[root@~]# dnf install elfutils-libelf-devel
[root@~]# /sbin/vboxconfig
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
如上结果表示安装成功