我正在尝试安装并运行 minikube,为此我需要安装 virtualbox。
我正在尝试在 Ubuntu 18.04 上安装 virtualbox。
我已经安装了 virtualbox,但是当我尝试运行它或 minikube 时,我会收到以下错误:
警告:字符设备 /dev/vboxdrv 不存在。请安装 virtualbox-dkms 软件包和适当的标头,最有可能是 linux-headers-generic。
解决此问题所采取的步骤
sudo apt-get purge virtualbox
sudo apt-get install virtualbox
这导致:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
virtualbox-qt
Suggested packages:
vde2 virtualbox-guest-additions-iso
The following NEW packages will be installed:
virtualbox virtualbox-qt
0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded.
Need to get 25.7 MB of archives.
After this operation, 108 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ucmirror.canterbury.ac.nz/ubuntu bionic-updates/multiverse amd64 virtualbox amd64 5.2.10-dfsg-6ubuntu18.04.1 [17.1 MB]
Get:2 http://ucmirror.canterbury.ac.nz/ubuntu bionic-updates/multiverse amd64 virtualbox-qt amd64 5.2.10-dfsg-6ubuntu18.04.1 [8,580 kB]
Fetched 25.7 MB in 14s (1,820 kB/s)
Selecting previously unselected package virtualbox.
(Reading database ... 338152 files and directories currently installed.)
Preparing to unpack .../virtualbox_5.2.10-dfsg-6ubuntu18.04.1_amd64.deb ...
Unpacking virtualbox (5.2.10-dfsg-6ubuntu18.04.1) ...
Selecting previously unselected package virtualbox-qt.
Preparing to unpack .../virtualbox-qt_5.2.10-dfsg-6ubuntu18.04.1_amd64.deb ...
Unpacking virtualbox-qt (5.2.10-dfsg-6ubuntu18.04.1) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.1) ...
Setting up virtualbox (5.2.10-dfsg-6ubuntu18.04.1) ...
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; generated)
Active: failed (Result: exit-code) since Fri 2018-08-03 17:03:20 NZST; 14ms ago
Docs: man:systemd-sysv-generator(8)
Process: 30224 ExecStart=/etc/init.d/virtualbox start (code=exited, status=1/FAILURE)
Aug 03 17:03:20 anton-ThinkPad-T510 systemd[1]: Starting LSB: VirtualBox Linux kernel module...
Aug 03 17:03:20 anton-ThinkPad-T510 virtualbox[30224]: * Loading VirtualBox kernel modules...
Aug 03 17:03:20 anton-ThinkPad-T510 virtualbox[30224]: * No suitable module for running kernel found
Aug 03 17:03:20 anton-ThinkPad-T510 virtualbox[30224]: ...fail!
Aug 03 17:03:20 anton-ThinkPad-T510 systemd[1]: virtualbox.service: Control process exited, code=exited status=1
Aug 03 17:03:20 anton-ThinkPad-T510 systemd[1]: virtualbox.service: Failed with result 'exit-code'.
Aug 03 17:03:20 anton-ThinkPad-T510 systemd[1]: Failed to start LSB: VirtualBox Linux kernel module.
Processing triggers for bamfdaemon (0.5.3+18.04.20180207.2-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for systemd (237-3ubuntu10.3) ...
Processing triggers for man-db (2.8.3-2) ...
Processing triggers for shared-mime-info (1.9-2) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Setting up virtualbox-qt (5.2.10-dfsg-6ubuntu18.04.1) ...
Processing triggers for ureadahead (0.100.0-20) ...
我还检查了是否已安装错误中提到的所需依赖项:
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.10-dfsg-6ubuntu18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
sudo apt-get install linux-headers-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
linux-headers-generic is already the newest version (4.15.0.29.31).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
答案1
要运行virtualbox,您需要将一些模块加载到内核中。您要么拥有与您的内核匹配的二进制模块,要么您可以从与您的内核匹配的源代码编译它们。您似乎没有这些模块,并且编译它们失败或未尝试。
在我的系统上,驱动程序是用
/usr/lib/virtualbox/vboxdrv.sh setup
手动运行该命令并查找可能出现错误的提示。
答案2
在 BIOS 设置中禁用安全启动。这对我有用:)
答案3
对于 Kali Linux 安全启动已禁用
使用命令重新启动系统reboot
。我遇到了完全相同的错误,重新启动后删除了该警告,并Job for virtualbox.service failed because the control process exited with error code.
在安装 virtualbox-qt 时删除了错误消息。
禁用安全启动的简单解决方案
运行命令sudo dpkg-reconfigure virtualbox-dkms
、sudo dpkg-reconfigure virtualbox
、 和sudo modprobe vboxdrv
添加缺少的模块。
启用安全启动的解决方案
使用安全启动,您将无法sudo modprobe vboxdrv
成功运行,因为使用的密钥不在 MOK 列表中。
- 使用 . 安装 mokutil
sudo apt install mokutil
。 - 请求将已创建的密钥注册到计算机,然后输入稍后需要使用的密码:
sudo mokutil --import /var/lib/dkms/mok.pub
/var/lib/dkms/mok.pub
是用于签署安全启动模块的默认密钥。 - 重新启动系统,您将看到 MOK 管理器。选择注册密钥并选择继续。然后选择确认并输入密钥的密码。按重新启动按钮并登录回 Linux 系统。
- 检查您是否已注册密钥您应该看到包含密钥名称的
sudo dmesg | grep cert
文本。integrity: Loaded X.509 cert 'DKMS module signing key:
DKMS module signing key
- 重新安装 linux 头文件包,
sudo apt reinstall linux-headers-$(uname -r)
以便dkms
自动签署模块并添加它们。 - 再次重新启动
/dev/vboxdrv
设备即可出现。学分:https://wiki.debian.org/SecureBoot?action=quicklink#Making_DKMS_modules_signing_by_DKMS_signing_key_usable_with_the_secure_boot
这已在 Debian Unstable (Sid) 上成功测试。