在 Debian 上安装 VirtualBox 时出现的内核头文件问题

在 Debian 上安装 VirtualBox 时出现的内核头文件问题

我正在尝试在我的 Debian 9 版本上安装 virtual box-5.2(从网站获取 .deb 文件)。目前我的内核:Linux 4.9.0

当我运行时:sudo dpkg -I virtualbox-5.2_5.2.12-122591~Debian~stretch_amd64.deb我收到以下错误消息:

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.
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.

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

但是当我尝试使用以下命令安装或升级头文件时sudo apt-get install linux-headers-$(uname -r),linux 告诉我,头文件已经安装。当我运行时,/sbin/vboxconfig我收到与上面相同的错误消息。

有人可以帮忙解决这个问题吗?谢谢!

答案1

如果安装后没有rebooted安装,就会出现此错误,所以应该是这样。

#shutdown -r now OR #reboot

然后作为 root 或 sudo rum:

#vboxconfig

还要确保您安装了开发工具:

#sudo apt update
#sudo apt install build-essential

答案2

如果你使用gdebi它应该引入所有依赖项。

不过我添加了虚拟盒/etc/apt/source.list.d/virtual-box.apt-sources.list

echo "deb http://download.virtualbox.org/virtualbox/debian jessie contrib" |sudo tee /etc/apt/source.list.d/virtual-box.apt-sources.list
sudo apt-get update
sudo apt-get install virtualbox-5.2 #would be nice if we could just specify the series.

相关内容