我在 Ubuntu 18.04.2 LTS 上,在安装 VirtualBox 时遇到了问题:
$ sudo apt install virtualbox
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
virtualbox-dkms 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, 0 to remove and 10 not upgraded.
Need to get 0 B/26.3 MB of archives.
After this operation, 113 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Selecting previously unselected package virtualbox-dkms.
(Reading database ... 242951 files and directories currently installed.)
Preparing to unpack .../virtualbox-dkms_5.2.18-dfsg-2~ubuntu18.04.5_all.deb ...
Unpacking virtualbox-dkms (5.2.18-dfsg-2~ubuntu18.04.5) ...
Selecting previously unselected package virtualbox.
Preparing to unpack .../virtualbox_5.2.18-dfsg-2~ubuntu18.04.5_amd64.deb ...
Unpacking virtualbox (5.2.18-dfsg-2~ubuntu18.04.5) ...
Selecting previously unselected package virtualbox-qt.
Preparing to unpack .../virtualbox-qt_5.2.18-dfsg-2~ubuntu18.04.5_amd64.deb ...
Unpacking virtualbox-qt (5.2.18-dfsg-2~ubuntu18.04.5) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Setting up virtualbox-dkms (5.2.18-dfsg-2~ubuntu18.04.5) ...
Loading new virtualbox-5.2.18 DKMS files...
Building for 5.0.0-21-generic
Building initial module for 5.0.0-21-generic
ERROR (dkms apport): kernel package linux-headers-5.0.0-21-generic is not supported
Error! Bad return status for module build on kernel: 5.0.0-21-generic (x86_64)
Consult /var/lib/dkms/virtualbox/5.2.18/build/make.log for more information.
Setting up virtualbox (5.2.18-dfsg-2~ubuntu18.04.5) ...
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 2019-07-12 11:09:28 EDT; 9ms ago
Docs: man:systemd-sysv-generator(8)
Process: 9266 ExecStart=/etc/init.d/virtualbox start (code=exited, status=1/FAILURE)
Jul 12 11:09:28 bruno-meerkat systemd[1]: Starting LSB: VirtualBox Linux kernel module...
Jul 12 11:09:28 bruno-meerkat virtualbox[9266]: * Loading VirtualBox kernel modules...
Jul 12 11:09:28 bruno-meerkat virtualbox[9266]: * No suitable module for running kernel found
Jul 12 11:09:28 bruno-meerkat virtualbox[9266]: ...fail!
Jul 12 11:09:28 bruno-meerkat systemd[1]: virtualbox.service: Control process exited, code=exited status=1
Jul 12 11:09:28 bruno-meerkat systemd[1]: virtualbox.service: Failed with result 'exit-code'.
Jul 12 11:09:28 bruno-meerkat 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.24) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for shared-mime-info (1.9-2) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Setting up virtualbox-qt (5.2.18-dfsg-2~ubuntu18.04.5) ...
Processing triggers for ureadahead (0.100.0-21) ...
问题的第一个迹象表明不支持 linux-headers-5.0.0-21-generic。我该如何解决这个问题?
答案1
此 VirtualBox 版本对于内核 5.x 来说太旧了。您需要 Oracle 的 VirtualBox 6。
VirtualBox 6.0.4(2019 年 1 月 28 日发布)
这是维护版本。修复和/或添加了下列内容:
Virtualization core: support Shanghai/Zhaoxin CPUs. User interface: handle command line arguments to VirtualBox correctly (bugs #18206 and #18197) User interface: improvements to machine manager window, virtual optical disk creator, storage selector window and log viewer window User interface: various small fixes and improvements User interface: fix incorrect restoring of main window position (bug #18367) Audio: implemented time scheduling for the AC'97 device emulation to keep audio and video in sync Graphics: basic support for VMSVGA graphics device in virtual machines using EFI Network: fix occasional NATNet crashes (bug #13899) Network: worked around problems in certain PCnet drivers on old operating systems Serial: fixed connecting to pseudo terminals on POSIX hosts (6.0.0 regression; bug #18319) Linux hosts and guests: fix for building kernel modules against Linux 5.0. Thank you Kyle Laker
整体变更日志
首先,清除您安装的 VirtualBox 版本。
然后添加上游 VirtualBox 存储库,即sources.list
Oracle 的条目:
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" >> /etc/apt/sources.list.d/virtualbox.list'
添加存储库的签名密钥:
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
最后:
sudo apt update && sudo apt install virtualbox-6.0