错误:未找到内核头文件。(但它们已就位)

错误:未找到内核头文件。(但它们已就位)

我正在尝试在 VirtualBox 4.04 中安装 Guest Additions。主机操作系统是 Ubuntu 桌面 11.04 64 位,客户操作系统是 Ubuntu 服务器 11.10 64 位。

$ sudo ./VBoxLinuxAdditions.run

经过一些输出后,会打印以下行:

The headers for the current running kernel were not found.

但标题安装,至少相应地dpkg

$ dpkg --get-selections | grep linux-headers
linux-headers-3.0.0-12            install
linux-headers-3.0.0-12-server     install
linux-headers-server              install

运行的内核是:

$ uname -a
Linux foobar 3.0.0-12-server #20-Ubuntu SMP Fri Oct 7 16:36:30 UTC 2011 x86_64 x86_64 X86_64 GNU/Linux

我该如何修复这个问题以便 Guest Additions 安装程序能够找到内核头?

更新:添加完整输出。

The headers for the current running kernel were not found. If the module compilation fails then this could be the reason.

Building the main Guest Additions module ...done.
Building the shared folder support module ...fail!
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Installing the Window System drivers ...fails!
(Could not find the X.Org or XFree86 Window System).

我不在乎失败 #2,因为那是一台服务器,我不需要 X 服务器。但我需要共享文件夹支持。

更多细节:

$ tail /val/log/vboxadd-install.log
..........
cc1: some warnings being treated as errors
make[2]: *** [/tmp/vbox.0/vfsmod.o] Error 1
make[1]: *** [_module_/tmp/vbox.0] Error 2
make: *** [vboxsf] Error 2

答案1

此信息具有误导性。

就我的情况来说,它实际上缺少 dkms,因此在安装附加程序之前,请运行

sudo apt-get install build-essential linux-headers-`uname -r` dkms

答案2

(尽管这个问题有一个可以接受的答案,但我还是添加了这个答案,以防它能帮助别人……)

虽然我有相同的症状,但我尝试了针对这个问题的所有建议,但都不起作用。我终于找到了这个帖子暗示这是 VirtualBox 版本Linux 内核版本未更新。

因此,如果对您没有任何帮助,请尝试从以下位置安装最新版本:http://download.virtualbox.org/virtualbox/(撰写本文时,这是4.2.6对于基于 Debian 的系统)。

答案3

dkms我通过安装和升级我的 VirtualBox 版本修复了这个错误。事实证明旧版本的 VirtualBox 客户机添加组件通常无法与最新内核兼容。

答案4

使用以下命令安装建议的软件包后:

sudo apt-get install build-essential linux-headers-`uname -r` dkms

我按照 dwurf 的建议升级了 VirtualBox 版本。这帮我解决了问题。

相关内容