Ubuntu 16.04:VirtualBox错误:未安装内核驱动程序(rc=-1908)

我的VirtualBox在启动虚拟机时出现了以下错误:
Kernel driver not installed (rc=-1908) VirtualBox Linux内核驱动程序(vboxdrv)未加载或/dev/vboxdrv存在权限问题。请安装virtualbox-dkms软件包并以root身份执行'modprobe vboxdrv'来加载内核模块。 如果您的发行版中有此软件包,请先安装DKMS软件包。该软件包可跟踪Linux内核的更改,并在必要时重新编译vboxdrv内核模块。
where: suplibOsInit what: 3 VERR_VM_DRIVER_NOT_INSTALLED (-1908) - The support driver is not installed. On linux, open returned ENOENT.
我按照指示安装了DKMS软件包,但收到了已经安装的消息。执行
sudo modprobe vboxdrv

导致出现了这个错误:
modprobe: FATAL: Module vboxdrv not found in directory /lib/modules/4.15.0-041500rc2-lowlatency

我尝试重新安装内核和virtualbox-dkms。
sudo apt install --reinstall linux-headers-$(uname -r) virtualbox-dkms dkms

我得到了这个输出。
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reinstallation of linux-headers-4.15.0-041500rc2-lowlatency is not possible, it cannot be downloaded.
The following additional packages will be installed:
  virtualbox virtualbox-qt
Suggested packages:
  vde2 virtualbox-guest-additions-iso
The following NEW packages will be installed:
  virtualbox virtualbox-dkms virtualbox-qt
0 upgraded, 3 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 66.3 kB/22.4 MB of archives.
After this operation, 95.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ch.archive.ubuntu.com/ubuntu xenial-updates/main amd64 dkms all 2.2.0.3-2ubuntu11.5 [66.3 kB]
Fetched 66.3 kB in 0s (477 kB/s)
(Reading database ... 531094 files and directories currently installed.)
Preparing to unpack .../dkms_2.2.0.3-2ubuntu11.5_all.deb ...
Unpacking dkms (2.2.0.3-2ubuntu11.5) over (2.2.0.3-2ubuntu11.5) ...
Selecting previously unselected package virtualbox-dkms.
Preparing to unpack .../virtualbox-dkms_5.0.40-dfsg-0ubuntu1.16.04.2_all.deb ...
Unpacking virtualbox-dkms (5.0.40-dfsg-0ubuntu1.16.04.2) ...
Selecting previously unselected package virtualbox.
Preparing to unpack .../virtualbox_5.0.40-dfsg-0ubuntu1.16.04.2_amd64.deb ...
Unpacking virtualbox (5.0.40-dfsg-0ubuntu1.16.04.2) ...
Selecting previously unselected package virtualbox-qt.
Preparing to unpack .../virtualbox-qt_5.0.40-dfsg-0ubuntu1.16.04.2_amd64.deb ...
Unpacking virtualbox-qt (5.0.40-dfsg-0ubuntu1.16.04.2) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu21.1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu5.1) ...
Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20160824-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Processing triggers for shared-mime-info (1.5-2ubuntu0.1) ...
Processing triggers for menu (2.1.47ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.15-0ubuntu1) ...
Setting up dkms (2.2.0.3-2ubuntu11.5) ...
Setting up virtualbox-dkms (5.0.40-dfsg-0ubuntu1.16.04.2) ...
Loading new virtualbox-5.0.40 DKMS files...
First Installation: checking all kernels...
Building only for 4.15.0-041500rc2-lowlatency
Building initial module for 4.15.0-041500rc2-lowlatency
ERROR (dkms apport): kernel package linux-headers-4.15.0-041500rc2-lowlatency is not supported
Error! Bad return status for module build on kernel: 4.15.0-041500rc2-lowlatency (x86_64)
Consult /var/lib/dkms/virtualbox/5.0.40/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; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Die 2018-02-20 20:50:55 CET; 7ms ago
     Docs: man:systemd-sysv-generator(8)
  Process: 10139 ExecStart=/etc/init.d/virtualbox start (code=exited, status=1/FAILURE)

Feb 20 20:50:55 matteo-3 systemd[1]: Starting LSB: VirtualBox Linux kernel .....
Feb 20 20:50:55 matteo-3 virtualbox[10139]:  * Loading VirtualBox kernel mod....
Feb 20 20:50:55 matteo-3 virtualbox[10139]:  * No suitable module for runnin...d
Feb 20 20:50:55 matteo-3 virtualbox[10139]:    ...fail!
Feb 20 20:50:55 matteo-3 systemd[1]: virtualbox.service: Control process ex...=1
Feb 20 20:50:55 matteo-3 systemd[1]: Failed to start LSB: VirtualBox Linux ...e.
Feb 20 20:50:55 matteo-3 systemd[1]: virtualbox.service: Unit entered faile...e.
Feb 20 20:50:55 matteo-3 systemd[1]: virtualbox.service: Failed with result...'.
Hint: Some lines were ellipsized, use -l to show in full.
Setting up virtualbox (5.0.40-dfsg-0ubuntu1.16.04.2) ...
vboxweb.service is a disabled or a static unit, 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; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Die 2018-02-20 20:50:57 CET; 7ms ago
     Docs: man:systemd-sysv-generator(8)
  Process: 10441 ExecStart=/etc/init.d/virtualbox start (code=exited, status=1/FAILURE)

Feb 20 20:50:56 matteo-3 systemd[1]: Starting LSB: VirtualBox Linux kernel .....
Feb 20 20:50:57 matteo-3 virtualbox[10441]:  * Loading VirtualBox kernel mod....
Feb 20 20:50:57 matteo-3 virtualbox[10441]:  * No suitable module for runnin...d
Feb 20 20:50:57 matteo-3 virtualbox[10441]:    ...fail!
Feb 20 20:50:57 matteo-3 systemd[1]: virtualbox.service: Control process ex...=1
Feb 20 20:50:57 matteo-3 systemd[1]: Failed to start LSB: VirtualBox Linux ...e.
Feb 20 20:50:57 matteo-3 systemd[1]: virtualbox.service: Unit entered faile...e.
Feb 20 20:50:57 matteo-3 systemd[1]: virtualbox.service: Failed with result...'.
Hint: Some lines were ellipsized, use -l to show in full.
Setting up virtualbox-qt (5.0.40-dfsg-0ubuntu1.16.04.2) ...
Processing triggers for menu (2.1.47ubuntu1) ...

这篇文章中,有几句话引起了我的注意:
Building initial module for 4.15.0-041500rc2-lowlatency
ERROR (dkms apport): kernel package linux-headers-4.15.0-041500rc2-lowlatency is not supported
Error! Bad return status for module build on kernel: 4.15.0-041500rc2-lowlatency (x86_64)

你有没有办法修复我的Virtualbox?是不是我的内核不被VirtualBox支持?如果是的话,我该如何切换到一个旧的/受支持的内核?

你能否在终端中使用“virtualbox”命令启动VirtualBox并向我们展示输出?另外,你正在使用哪个版本的VirtualBox? - 2017561-1
`WARNING: The character device /dev/vboxdrv does not exist. Please install the virtualbox-dkms package and the appropriate headers, most likely linux-headers-lowlatency. You will not be able to start VMs until this problem is fixed. ` - Mat D.
我今天早上遇到了同样的问题。昨天一切正常,但今天我遇到了“内核错误”。我花了一些时间阅读和尝试不同的选项。过了3个小时,我找到了这个论坛:https://forums.virtualbox.org/viewtopic.php?f=7&t=91833 他们提到了降级内核的选项。我尝试了那个方法,现在Vbox可以使用了。 以下是如何恢复到之前的内核: http://karlcode.owtelse.com/blog/2017/03/13/reverting-to-a-previous-kernel/ - churta
我刚刚在这里发布了解决此问题的方法:链接 - Adriana Hernández
这个回答解决了你的问题吗?Virtualbox内核驱动程序未安装 - karel
6个回答

我遇到了同样的问题,之前删除了我认为已经过时的内核版本。但结果却出现了麻烦。
我通过运行以下命令解决了这个问题:
sudo apt install --reinstall linux-headers-$(uname -r) virtualbox-dkms dkms

在执行了那个命令之后,VirtualBox完美地运行起来了!
我的设置如下:
- Ubuntu 16.04 LTS - VirtualBox 5.1.38

非常感谢您的辛勤工作。 - balaji
在Ubuntu 20.10和VirtualBox 6.1.14上对我有效。 - Janos
适用于Ubuntu 18.04和VirtualBox 5.2。 - rcarba
谢谢,上面的解决方案在“Ubuntu 21.04”中有效,我还需要运行额外的命令“sudo modprobe vboxdrv”。 - Swapnil
很遗憾,这个方法在Ubuntu 20上不起作用,但是它同样适用于Elementary OS。 - alkanstein


在上面链接的第3步中,当我导入公钥时,mokutil 给出了以下错误提示: 此系统不支持 EFI 变量 - Mat D.

最近在Ubuntu 18.04上遇到了同样的问题。显然,虚拟机6.+与gcc-7存在一些问题。以下步骤对我起到了作用:
卸载虚拟机
sudo apt-get purge virtualbox-*
安装gcc-8
sudo apt-get install gcc-8 g++-8
将默认gcc设置为gcc-8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
然后使用Debian安装程序重新安装虚拟机!

这很有帮助。不幸的是,因为它没有得到赞同,我并没有真正注意到它,只能通过艰难的方式来弄清楚。 - Abdelrahman Shoman

升级内核到4.15版本后,在Virtualbox中出现的问题:
modprobe: FATAL: Module vboxdrv not found in directory /lib/modules/4.15.7-041507-generic

这个对我解决了问题。
sudo apt-get install virtualbox-dkms linux-headers-lowlatency

实际上不要费心去看教程:
打开vm但不要启动它,打开终端并输入:
sudo modprobe vboxdrv

然后在vm上单击start

享受吧,但别忘了每次想使用vm时都要这样做,特别是对于Kali。今天的操作系统不带dir,这很棒。所以不必担心头文件、uname和更新。


我正在使用基于Ubuntu 20.04的Linux Mint Mate 20.1,并且最近遇到了问题。

安装其他人提到的头文件并没有起作用,而且占用了几个GB的磁盘空间。

背景

我之前升级过内核,但在VirtualBox中很长一段时间都没有问题。但突然出现了这个问题。

解决方案

对我有效的解决方案是在安装系统时使用默认内核。可以通过配置grub来使用原始内核来实现。

请参考:如何使用旧版本的内核启动?

e.g

  • sudo vi /etc/default/grub,将GRUB_DEFAULT=1>2修改为:
    • 1Advanced options for ubuntu的索引,索引从0开始。
    • 2是默认内核的子索引,在Advanced options for ubuntu中。
  • sudo update-grub
  • sudo reboot

提示

  • 您可以选择性地删除手动安装的不再使用的内核。
    在我的情况下,这节省了8GB的空间!!!