如何为虚拟机安装 Linux“头”文件?

如何为虚拟机安装 Linux“头”文件?

我在运行 Debian 9 的桌面上安装了 virtualbox,并下载了一个虚拟机文件并将其导入到 virtualbox 中。问题是,当我尝试启动虚拟机时,它告诉我在终端中运行“/sbin/vboxconfig”,所以我这样做了,我得到了这个:

root@MaxPC:/home/maxwell# /sbin/vboxconfig
Created symlink /etc/systemd/system/multi-user.target.wants/vboxdrv.service → /lib/systemd/system/vboxdrv.service.
Created symlink /etc/systemd/system/multi-user.target.wants/vboxballoonctrl-service.service → /lib/systemd/system/vboxballoonctrl-service.service.
Created symlink /etc/systemd/system/multi-user.target.wants/vboxautostart-service.service → /lib/systemd/system/vboxautostart-service.service.
Created symlink /etc/systemd/system/multi-user.target.wants/vboxweb-service.service → /lib/systemd/system/vboxweb-service.service.
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
    linux-headers-amd64 linux-headers-4.18.0-0.bpo.1-amd64
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
    linux-headers-amd64 linux-headers-4.18.0-0.bpo.1-amd64

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

然后我运行 'sudo apt-get install linux-headers-4.18.0-0.bpo.1-amd64' 看看是否可以解决这个问题,但我得到了这个:

root@MaxPC:/home/maxwell# sudo apt-get install linux-headers-4.18.0-0.bpo.1-amd64
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 linux-headers-4.18.0-0.bpo.1-amd64 : Depends: linux-compiler-gcc-6-x86 (>= 4.14.17-1~) but 4.9.130-2 is to be installed
E: Unable to correct problems, you have held broken packages.

我到底该怎么做才能启动我的虚拟机?

答案1

正如中提到的这个错误报告您需要指定目标版本。尝试:

sudo apt-get install -t stretch-backports linux-headers-4.18.0-0.bpo.1-amd64

相关内容