Virtual Box 在 16.04(xenial)上“系统当前未设置为构建内核模块”

Virtual Box 在 16.04(xenial)上“系统当前未设置为构建内核模块”

我尝试安装虚拟盒但出现以下错误。

$ sudo /sbin/vboxconfig 
[sudo] password for dude: 
vboxdrv.sh: Building VirtualBox kernel modules.
This system is not currently set up to build kernel modules (system extensions).
Running the following commands should set the system up correctly:

  apt-get install linux-headers-4.4.0-24-generic
(The last command may fail if your system is not fully updated.)
  apt-get install linux-headers-generic
vboxdrv.sh: failed: Look at /var/log/vbox-install.log to find out what went wrong.
This system is not currently set up to build kernel modules (system extensions).
Running the following commands should set the system up correctly:

  apt-get install linux-headers-4.4.0-24-generic
(The last command may fail if your system is not fully updated.)
  apt-get install linux-headers-generic

There were problems setting up VirtualBox.  To re-start the set-up process, run
  /sbin/vboxconfig
as root.

我当前的内核是:

$ uname -r
4.4.0-24-generic

尝试升级标题给我以下信息。

$ sudo apt-get upgrade && sudo apt-get install linux-headers-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
linux-headers-generic is already the newest version (4.4.0.21.22).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

尝试直接从 deb 安装 linux-headers-4.4.0-24-generic,仍然出现错误。从 apt-get 中我得到:

$ sudo apt-get install linux-headers-4.4.0-24-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package linux-headers-4.4.0-24-generic is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'linux-headers-4.4.0-24-generic' has no installation candidate

肯定有办法解决这个问题。有什么建议吗?帮帮忙!

答案1

您提供的输出apt-cache policy linux-headers-4.4.0-24-generic是此问题根本原因的重要线索。由于命令报告(部分),Candidate: none很明显您的系统上未正确设置存储库,因此它不知道在哪里找到所需的包。将其添加http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main到您的源列表中,您应该能够安装该包。

为了让您能够检查其余来源列表,以下是我的列表,仅供参考(我删除了注释掉的行)。

deb http://us.archive.ubuntu.com/ubuntu/ trusty main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty main restricted
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb http://us.archive.ubuntu.com/ubuntu/ trusty universe
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty universe
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates universe
deb http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb http://us.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://us.archive.ubuntu.com/ubuntu/ trusty-security main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-security main restricted
deb http://us.archive.ubuntu.com/ubuntu/ trusty-security universe
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-security universe
deb http://us.archive.ubuntu.com/ubuntu/ trusty-security multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-security multiverse
deb http://extras.ubuntu.com/ubuntu trusty main
deb-src http://extras.ubuntu.com/ubuntu trusty main

相关内容