在 Ubuntu 20.04 中安装 VirtualBox — 处理各种软件包时遇到错误

在 Ubuntu 20.04 中安装 VirtualBox — 处理各种软件包时遇到错误
 $ sudo apt install virtualbox virtualbox-ext-pack 
 Reading package lists... Done  
 Building dependency tree        
 Reading state information... Done 
 The following additional packages will be installed: 
   libgsoap-2.8.91 libqt5opengl5 libvncserver1 virtualbox-dkms virtualbox-qt 
 Suggested packages: 
   vde2 virtualbox-guest-additions-iso 
 The following NEW packages will be installed: 
   libgsoap-2.8.91 libqt5opengl5 libvncserver1 virtualbox virtualbox-dkms virtualbox-ext-pack 
   virtualbox-qt 
 0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded. 
 Need to get 0 B/44.3 MB of archives. 
 After this operation, 180 MB of additional disk space will be used. 
 Do you want to continue? [Y/n] Y 
 Preconfiguring packages ... 
 Selecting previously unselected package virtualbox-dkms. 
(Reading database ... 314591 files and directories currently installed.) 
 Preparing to unpack .../0-virtualbox-dkms_6.1.10-dfsg-1~ubuntu1.20.04.1_amd64.deb ... 
 Unpacking virtualbox-dkms (6.1.10-dfsg-1~ubuntu1.20.04.1) ... 
 Selecting previously unselected package libgsoap-2.8.91:amd64. 
 Preparing to unpack .../1-libgsoap-2.8.91_2.8.91-2_amd64.deb ... 
 Unpacking libgsoap-2.8.91:amd64 (2.8.91-2) ... 
 Selecting previously unselected package libvncserver1:amd64. 
 Preparing to unpack .../2-libvncserver1_0.9.12+dfsg-9ubuntu0.3_amd64.deb ... 
 Unpacking libvncserver1:amd64 (0.9.12+dfsg-9ubuntu0.3) ... 
 Selecting previously unselected package virtualbox. 
 Preparing to unpack .../3-virtualbox_6.1.10-dfsg-1~ubuntu1.20.04.1_amd64.deb ... 
 Unpacking virtualbox (6.1.10-dfsg-1~ubuntu1.20.04.1) ... 
 Selecting previously unselected package virtualbox-ext-pack. 
 Preparing to unpack .../4-virtualbox-ext-pack_6.1.10-1~ubuntu1.20.04.1_all.deb ... 
 License has already been accepted. 
 Unpacking virtualbox-ext-pack (6.1.10-1~ubuntu1.20.04.1) ... 
 Selecting previously unselected package libqt5opengl5:amd64. 
 Preparing to unpack .../5-libqt5opengl5_5.12.8+dfsg-0ubuntu1_amd64.deb ... 
 Unpacking libqt5opengl5:amd64 (5.12.8+dfsg-0ubuntu1) ... 
 Selecting previously unselected package virtualbox-qt. 
 Preparing to unpack .../6-virtualbox-qt_6.1.10-dfsg-1~ubuntu1.20.04.1_amd64.deb ... 
 Unpacking virtualbox-qt (6.1.10-dfsg-1~ubuntu1.20.04.1) ... 
 Setting up libvncserver1:amd64 (0.9.12+dfsg-9ubuntu0.3) ... 
 Setting up libqt5opengl5:amd64 (5.12.8+dfsg-0ubuntu1) ... 
 Setting up libgsoap-2.8.91:amd64 (2.8.91-2) ... 
 Setting up virtualbox-dkms (6.1.10-dfsg-1~ubuntu1.20.04.1) ... 
 Loading new virtualbox-6.1.10 DKMS files... 
 Building for 5.4.0-58-generic 5.8.1-050801-generic 
 Building initial module for 5.4.0-58-generic 
 Secure Boot not enabled on this system. 
 Done. 
  
 vboxdrv.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.4.0-58-generic/updates/dkms/ 
  
 vboxnetadp.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.4.0-58-generic/updates/dkms/ 
  
 vboxnetflt.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.4.0-58-generic/updates/dkms/ 
  
 depmod......... 
  
 DKMS: install completed. 
 Building initial module for 5.8.1-050801-generic 
 ERROR (dkms apport): kernel package linux-headers-5.8.1-050801-generic is not supported 
 Error! Bad return status for module build on kernel: 5.8.1-050801-generic (x86_64) 
 Consult /var/lib/dkms/virtualbox/6.1.10/build/make.log for more information. 
 dpkg: error processing package virtualbox-dkms (--configure):
 installed virtualbox-dkms package post-installation script subprocess returned error exit status
 10 
 dpkg: dependency problems prevent configuration of virtualbox:
 virtualbox depends on virtualbox-dkms (>= 6.1.10-dfsg-1~ubuntu1.20.04.1) | virtualbox-source (>=
 6.1.10-dfsg-1~ubuntu1.20.04.1) | virtualbox-modules; however:
  Package virtualbox-dkms is not configured yet.
  Package virtualbox-source is not installed.
  Package virtualbox-modules is not installed.
  Package virtualbox-dkms which provides virtualbox-modules is not configured yet. 
  
 dpkg: error processing package virtualbox (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of virtualbox-ext-pack:
 virtualbox-ext-pack depends on virtualbox (>= 6.1.10-dfsg-0~) | virtualbox-6.1; however:
  Package virtualbox is not configured yet.
  Package virtualbox-6.1 is not installed.
 virtualbox-ext-pack depends on virtualbox (<< 6.1.10-dfsg-z) | virtualbox-6.1; however:
  Package virtualbox is not configured yet.
  Package virtualbox-6.1 is not installed. 
  
 dpkNo apport report written because the error message indicates its a followup error from a previous failure. 
 No apport report written because the error message indicates its a followup error from a previous failure. 
 No apport report written because MaxReports is reached already 
 g: error processing package virtualbox-ext-pack (--configure): 
  dependency problems - leaving unconfigured
 dpkg: dependency problems prevent configuration of virtualbox-qt: 
 virtualbox-qt depends on virtualbox (= 6.1.10-dfsg-1~ubuntu1.20.04.1); however: 
   Package virtualbox is not configured yet. 

 dpkg: error processing package virtualbox-qt (--configure): 
  dependency problems - leaving unconfigured 
 Processing triggers for desktop-file-utils (0.24-1ubuntu3) ... 
 Processing triggers for mime-support (3.64ubuntu1) ... 
 Processing triggers for hicolor-icon-theme (0.17-2) ... 
 Processing triggers for gnome-menus (3.36.0-1ubuntu1) ... 
 Processing triggers for libc-bin (2.31-0ubuntu9.1) ... 
 Processing triggers for systemd (245.4-4ubuntu3.3) ... 
 Processing triggers for man-db (2.9.1-1) ... 
 Processing triggers for ureadahead (0.100.0-21) ... 
 Processing triggers for shared-mime-info (1.15-1) ... 
 Errors were encountered while processing: 
  virtualbox-dkms 
  virtualbox 
  virtualbox-ext-pack 
  virtualbox-qt 
 E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

我从那时起就知道:

Secure Boot not enabled on this system.你不觉得这里表达了些什么吗?

顺便说一句,如果您的机器支持虚拟机,那么您必须在启动配置中启用虚拟机。

因为这可能只是因为您的机器不支持它。

然后:

ERROR (dkms apport): kernel package linux-headers-5.8.1-050801-generic is not supported

不要低估@Pilot6 的回答,因为它将在未来解决许多头痛问题!

Ubuntu 作为 Linux 内核,最近发生了很多变化,许多应用程序停止按预期工作,这导致了调整、修改、复杂化以及像我这样的愤怒用户。

您需要安装:

Package virtualbox-source is not installed.
Package virtualbox-modules is not installed.

因此,

dpkg: dependency problems prevent configuration of virtualbox:

这好像是:

  • 首先你的内核不支持它
  • 第二,你需要安装缺少的模块
  • 第三次配置它们,如果自动安装不成功

答案2

我遇到了同样的错误,除了我使用的是带有 5.19 内核的 Ubuntu 22.04。

为我解决这个问题的方法是查看 /var/lib/dkms/virtualbox/6.1.10/build/make.log错误消息建议检出的文件。

该文件显示我当前使用的 gcc 版本是 11.2.0,但我的内核是用 gcc 12.2.0 或类似的版本构建的。所以我下载了 gcc 12: sudo apt-get install gcc-12

之后,我删除了/usr/bin/gcc符号链接并创建了一个指向 gcc-12 而不是 gcc-11 的新链接(在我的情况下):sudo ln -s /usr/bin/gcc-12 /usr/bin/gcc

清除 virtualbox 并重新安装

sudo apt-get purge virtualbox

sudo apt-get install virtualbox

没有错误!祝你好运!

答案3

您正在使用不受支持的主线内核5.8.1-050801-generic

Ubuntu 存储库中的 virtualbox 包与它不兼容,正如您所见,内核模块无法构建:

DKMS: install completed. 
 Building initial module for 5.8.1-050801-generic 
 ERROR (dkms apport): kernel package linux-headers-5.8.1-050801-generic is not supported 
 Error! Bad return status for module build on kernel: 5.8.1-050801-generic (x86_64) 
 Consult /var/lib/dkms/virtualbox/6.1.10/build/make.log for more information.

而且 Oracle 似乎还没有发布支持该5.8内核的 VB。我在 virtualbox.org 上没有看到 Ubuntu 20.10 的版本。

因此切换到 Ubuntu 内核,一切就可以正常工作。

相关内容