我知道这个问题有多个版本。所以我将尝试提供我所面临的问题以及我迄今为止尝试过的方法的全面细节。
问题
每当我尝试启动我添加的图像时,都会出现以下错误 Kernel driver not installed (rc=-1908)
无论我是否以 sudo 身份运行 VirtualBox,错误都是相同的。
建议修复
这是我尝试修复此问题的所有方法的列表。大多数建议都可以在网上的多个来源(无论是在 StackExchange 论坛还是在不同的网站上)找到。
显然,到目前为止,这些建议对我都不起作用。
建议 1:不要使用 VirtualBox 的 Apt 版本
我发现的一个建议这里(以及其他来源)是卸载 apt 版本的 VirtualBox 并在官方网站上安装包。我照做了,甚至还按照一些文章的建议安装了“VirtualBox 6.1.10 Oracle VM VirtualBox Extension Pack”。然而这无济于事。
建议 2:禁用安全启动
我的安全启动已被禁用。当我在进行 Windows 和 Ubuntu 的双启动时,我需要禁用它。我提到这一点是为了全面披露,但不确定这是否相关。建议 3:安装 virtualbox-dkms (和 linux-headers-generic)
许多文章和 stackoverflow 用户都建议这样做。回答结合了安装 dkms 和 linux 标头所需的所有命令。虽然这个特定的答案并没有真正得到赞同,但其他地方的类似答案似乎是可以接受的。但这并没有为我解决问题。(PS:编辑 2 列出了这些命令及其输出)你有什么建议吗?我遗漏了什么吗?
编辑 1:澄清
第一的:在这种情况下,“没有工作”和“没有修复”意味着当我尝试运行图像时,我仍然会收到相同的错误。以下是我收到的完整详细错误消息
Kernel driver not installed (rc=-1908)
The VirtualBox Linux kernel driver is either not loaded or not set up correctly. Please reinstall virtualbox-dkms package and load the kernel module by executing
'modprobe vboxdrv'
as root.
If your system has EFI Secure Boot enabled you may also 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.
where: suplibOsInit what: 3 VERR_VM_DRIVER_NOT_INSTALLED (-1908) - The support driver is not installed. On Linux, open returned ENOENT.
第二:当通过终端运行虚拟盒时,除了终端中的以下警告外,我还收到上述相同的错误
WARNING: The character device /dev/vboxdrv does not exist.
Please install the virtualbox-dkms package and the appropriate
headers, most likely linux-headers-generic.
You will not be able to start VMs until this problem is fixed.
(PS 我已经安装了 virtualbox-dkms 包,如编辑 2 中所示)。
编辑 2:建议 2 的命令及其输出
1.命令1: sudo apt-get install virtualbox-dkms
Reading package lists... Done
Building dependency tree
Reading state information... Done virtualbox-dkms is already the newest version (5.2.34-dfsg-0~ubuntu18.04.1).
The following packages were automatically installed and are no longer required:
kbuild libsdl-ttf2.0-0
module-assistant
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
2.命令2: sudo dpkg-reconfigure virtualbox-dkms
------------------------------
Deleting module version: 5.2.34
completely from the DKMS tree.
------------------------------
Done.
Loading new virtualbox-5.2.34 DKMS files...
Building for 5.3.0-59-generic
Building initial module for 5.3.0-59-generic
Error! Bad return status for module build on kernel: 5.3.0-59-generic (x86_64)
Consult /var/lib/dkms/virtualbox/5.2.34/build/make.log for more information.
Job for virtualbox.service failed because the control process exited with error code.
See "systemctl status virtualbox.service" and "journalctl -xe" for details.
invoke-rc.d: initscript virtualbox, action "restart" failed.
● virtualbox.service - LSB: VirtualBox Linux kernel module
Loaded: loaded (/etc/init.d/virtualbox; generated)
Active: failed (Result: exit-code) since Thu 2020-06-25 12:03:38 IST; 4ms ago
Docs: man:systemd-sysv-generator(8)
Process: 16118 ExecStart=/etc/init.d/virtualbox start (code=exited, status=1/FAILURE)
Jun 25 12:03:38 shouman-XPS-15-7590 systemd[1]: Starting LSB: VirtualBox Linux kernel module...
Jun 25 12:03:38 shouman-XPS-15-7590 virtualbox[16118]: * Loading VirtualBox kernel modules...
Jun 25 12:03:38 shouman-XPS-15-7590 virtualbox[16118]: * No suitable module for running kernel found
Jun 25 12:03:38 shouman-XPS-15-7590 virtualbox[16118]: ...fail!
Jun 25 12:03:38 shouman-XPS-15-7590 systemd[1]: virtualbox.service: Control process exited, code=exited status=1
Jun 25 12:03:38 shouman-XPS-15-7590 systemd[1]: virtualbox.service: Failed with result 'exit-code'.
Jun 25 12:03:38 shouman-XPS-15-7590 systemd[1]: Failed to start LSB: VirtualBox Linux kernel module.
此命令失败并将我引导至日志文件。以下是日志文件中的信息:
DKMS make.log for virtualbox-5.2.34 for kernel 5.3.0-59-generic (x86_64)
Thu Jun 25 12:03:36 IST 2020
make: Entering directory '/usr/src/linux-headers-5.3.0-59-generic'
CC [M] /var/lib/dkms/virtualbox/5.2.34/build/vboxdrv/linux/SUPDrv-linux.o
CC [M] /var/lib/dkms/virtualbox/5.2.34/build/vboxdrv/SUPDrv.o
CC [M] /var/lib/dkms/virtualbox/5.2.34/build/vboxdrv/SUPDrvGip.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
scripts/Makefile.build:288: recipe for target '/var/lib/dkms/virtualbox/5.2.34/build/vboxdrv/linux/SUPDrv-linux.o' failed
make[2]: *** [/var/lib/dkms/virtualbox/5.2.34/build/vboxdrv/linux/SUPDrv-linux.o] Error 1
make[2]: *** Waiting for unfinished jobs....
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
scripts/Makefile.build:288: recipe for target '/var/lib/dkms/virtualbox/5.2.34/build/vboxdrv/SUPDrv.o' failed
make[2]: *** [/var/lib/dkms/virtualbox/5.2.34/build/vboxdrv/SUPDrv.o] Error 1
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
scripts/Makefile.build:288: recipe for target '/var/lib/dkms/virtualbox/5.2.34/build/vboxdrv/SUPDrvGip.o' failed
make[2]: *** [/var/lib/dkms/virtualbox/5.2.34/build/vboxdrv/SUPDrvGip.o] Error 1
CC [M] /var/lib/dkms/virtualbox/5.2.34/build/vboxdrv/SUPDrvSem.o
CC [M] /var/lib/dkms/virtualbox/5.2.34/build/vboxdrv/SUPDrvTracer.o
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
scripts/Makefile.build:288: recipe for target '/var/lib/dkms/virtualbox/5.2.34/build/vboxdrv/SUPDrvSem.o' failed
make[2]: *** [/var/lib/dkms/virtualbox/5.2.34/build/vboxdrv/SUPDrvSem.o] Error 1
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
scripts/Makefile.build:288: recipe for target '/var/lib/dkms/virtualbox/5.2.34/build/vboxdrv/SUPDrvTracer.o' failed
make[2]: *** [/var/lib/dkms/virtualbox/5.2.34/build/vboxdrv/SUPDrvTracer.o] Error 1
scripts/Makefile.build:519: recipe for target '/var/lib/dkms/virtualbox/5.2.34/build/vboxdrv' failed
make[1]: *** [/var/lib/dkms/virtualbox/5.2.34/build/vboxdrv] Error 2
Makefile:1656: recipe for target '_module_/var/lib/dkms/virtualbox/5.2.34/build' failed
make: *** [_module_/var/lib/dkms/virtualbox/5.2.34/build] Error 2
make: Leaving directory '/usr/src/linux-headers-5.3.0-59-generic'
3.命令3: sudo dpkg-reconfigure virtualbox
vboxweb.service is a disabled or a static unit not running, not starting it.
Job for virtualbox.service failed because the control process exited with error code.
See "systemctl status virtualbox.service" and "journalctl -xe" for details.
invoke-rc.d: initscript virtualbox, action "restart" failed.
● virtualbox.service - LSB: VirtualBox Linux kernel module
Loaded: loaded (/etc/init.d/virtualbox; generated)
Active: failed (Result: exit-code) since Thu 2020-06-25 12:09:08 IST; 4ms ago
Docs: man:systemd-sysv-generator(8)
Process: 16596 ExecStart=/etc/init.d/virtualbox start (code=exited, status=1/FAILURE)
Jun 25 12:09:08 shouman-XPS-15-7590 systemd[1]: Starting LSB: VirtualBox Linux kernel module...
Jun 25 12:09:08 shouman-XPS-15-7590 virtualbox[16596]: * Loading VirtualBox kernel modules...
Jun 25 12:09:08 shouman-XPS-15-7590 virtualbox[16596]: * No suitable module for running kernel found
Jun 25 12:09:08 shouman-XPS-15-7590 virtualbox[16596]: ...fail!
Jun 25 12:09:08 shouman-XPS-15-7590 systemd[1]: virtualbox.service: Control process exited, code=exited status=1
Jun 25 12:09:08 shouman-XPS-15-7590 systemd[1]: virtualbox.service: Failed with result 'exit-code'.
Jun 25 12:09:08 shouman-XPS-15-7590 systemd[1]: Failed to start LSB: VirtualBox Linux kernel module.
4.命令4: sudo apt-get install linux-headers-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
kbuild libsdl-ttf2.0-0 linux-headers-4.15.0-106 linux-headers-4.15.0-106-generic module-assistant
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
linux-headers-4.15.0-108 linux-headers-4.15.0-108-generic
The following NEW packages will be installed:
linux-headers-4.15.0-108 linux-headers-4.15.0-108-generic
The following packages will be upgraded:
linux-headers-generic
1 upgraded, 2 newly installed, 0 to remove and 5 not upgraded.
Need to get 12.0 MB of archives.
After this operation, 89.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://qa.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-headers-4.15.0-108 all 4.15.0-108.109 [10.9 MB]
Get:2 http://qa.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-headers-4.15.0-108-generic amd64 4.15.0-108.109 [1,097 kB]
Get:3 http://qa.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-headers-generic amd64 4.15.0.108.96 [2,392 B]
Fetched 12.0 MB in 2s (6,355 kB/s)
Selecting previously unselected package linux-headers-4.15.0-108.
(Reading database ... 251776 files and directories currently installed.)
Preparing to unpack .../linux-headers-4.15.0-108_4.15.0-108.109_all.deb ...
Unpacking linux-headers-4.15.0-108 (4.15.0-108.109) ...
Selecting previously unselected package linux-headers-4.15.0-108-generic.
Preparing to unpack .../linux-headers-4.15.0-108-generic_4.15.0-108.109_amd64.deb ...
Unpacking linux-headers-4.15.0-108-generic (4.15.0-108.109) ...
Preparing to unpack .../linux-headers-generic_4.15.0.108.96_amd64.deb ...
Unpacking linux-headers-generic (4.15.0.108.96) over (4.15.0.106.94) ...
Setting up linux-headers-4.15.0-108 (4.15.0-108.109) ...
Setting up linux-headers-4.15.0-108-generic (4.15.0-108.109) ...
/etc/kernel/header_postinst.d/dkms:
* dkms: running auto installation service for kernel 4.15.0-108-generic
Kernel preparation unnecessary for this kernel. Skipping...
Building module:
cleaning build area...
make -j8 KERNELRELEASE=4.15.0-108-generic -C /lib/modules/4.15.0-108-generic/build M=/var/lib/dkms/virtualbox/5.2.34/build...(bad exit status: 2)
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/virtualbox-dkms.0.crash'
Error! Bad return status for module build on kernel: 4.15.0-108-generic (x86_64)
Consult /var/lib/dkms/virtualbox/5.2.34/build/make.log for more information.
...done.
Setting up linux-headers-generic (4.15.0.108.96) ...
libdvd-pkg: Checking orig.tar integrity...
/usr/src/libdvd-pkg/libdvdcss_1.4.2.orig.tar.bz2: OK
libdvd-pkg: `apt-get check` failed, you may have broken packages. Aborting...
答案1
因此,当我尝试更新问题以回应@user535733 评论时,我注意到日志文件中有一个 gcc 错误/var/lib/dkms/virtualbox/5.2.34/build/make.log
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
在此文章用户Ville Nummela (ville-nummela)
提到
为较新的内核构建内核驱动程序需要 gcc 4.9
我有一个旧的 gcc,这就是问题所在。更新我的 gcc 后,它现在运行正常。
gcc --version
gcc (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0
这也提到了这一点回答但我没有注意到它,因为它没有被赞成。
笔记::更新我的 gcc 后,我必须重新运行以下命令
sudo dpkg-reconfigure virtualbox-dkms
sudo dpkg-reconfigure virtualbox
希望这能在未来帮助别人
答案2
这是我针对同一问题所做的事情
apt-get autoremove virtualbox
这将从我的操作系统中完全删除虚拟盒,然后我选择使用以下步骤从 Oracle 存储库安装
使用以下命令导入 Oracle 公钥:
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
两个命令都应该输出好的这意味着密钥已成功导入
然后通过运行将 virtualbox 存储库添加到您的系统
echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | \
sudo tee -a /etc/apt/sources.list.d/virtualbox.list
你将使用以下方法更新软件包并安装最新的 virtualbox
sudo apt update
sudo apt install virtualbox-6.1
输入以下命令下载扩展包文件:
wget https://download.virtualbox.org/virtualbox/6.1.8/Oracle_VM_VirtualBox_Extension_Pack-6.1.8.vbox-extpack
下载完成后,使用以下命令导入扩展包:
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.1.8.vbox-extpack