2012-11-03 17:06:32 +0000 2012-11-03 17:06:32 +0000
38
38
Advertisement

无法安装虚拟盒,`"指定KERN_DIR=<目录>"`--安装虚拟盒到Debian?

Advertisement

我得到了这个错误。

Makefile:181: *** ******错误:无法找到当前Linux内核的来源。指定KERN\_DIR=并再次运行Make。停止。

基本上我正在做。

$ sudo /etc/init.d/vboxdrv setup
Removing existing VirtualBox non-DKMS kernel modules [OK]
Building the VirtualBox Guest Additions kernel modules
The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.
The missing package can be probably installed with
yum install kernel-devel-2.6.32-573.18.1.el6.x86_64

Building the main Guest Additions module [FAILED]
(Look at /var/log/vboxadd-install.log to find out what went wrong)

错误是:

Makefile:181: *** ******错误:无法找到当前Linux内核的源代码。指定KERN\_DIR= 然后再运行Make。停止

这个错误是什么,如何解决?

Advertisement
Advertisement

答案 (7)

34
34
34
2012-11-03 17:38:30 +0000

确保你安装了Kernel Headers Package。 http://www.cyberciti.biz/faq/howto-install-kernel-headers-package

Make sure you have updated version

Type the following command
$ sudo apt-get update

OR as root user enter:
# apt-get update

Search for kernel version (optional)

Type the following command:
$ apt-cache search linux-headers-$(uname -r)

Install linux-header package under Debina or Ubuntu Linux

Type the following command:
$ sudo apt-get install linux-headers-$(uname -r)

OR as root user:
# apt-get install linux-headers-$(uname -r)

编辑:

我只是碰巧需要在自己的服务器上也安装它,并且在尝试使用debian repos中的virtualbox时得到了同样的错误。我继续添加了VirtualBox repo并从那里安装。这样做比较好,因为它们是最新的。

As root

$ nano /etc/apt/sources.list

在下面添加一行 squeeze

deb http://download.virtualbox.org/virtualbox/debian squeeze contrib non-free

然后添加 apt-secure

$ wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -

的 Oracle 公钥,然后运行更新并安装最新的 4.Beta。 2

apt-get update
apt-get install virtualbox-4.2

安装dkms包,确保VirtualBox主机内核模块是最新的

apt-get install dkms

应该可以了。从VirtualBox的Linux网站上得到了这些说明,该网站目前似乎已经关闭,但链接是 https://www.virtualbox.org/wiki/Linux_Downloads

29
29
29
2014-07-19 12:20:11 +0000

如何解决Fedora/CentOS

首先确保你安装的软件包(尤其是内核)是最新的:

$ sudo yum update

如果它更新了内核版本,你必须重新启动,使uname -r/usr/src/kernels/中的目录名相匹配。然后

$ sudo yum install kernel-devel gcc
$ echo export KERN_DIR=/usr/src/kernels/`uname -r` >> ~/.bashrc
$ source ~/.bashrc # to set the variable in your current shell
$ sudo echo $KERN_DIR # verify the value is set
$ sudo ls $KERN_DIR # verify the directory exists

在这之后,编译VirtualBox内核模块应该没有任何问题。

源。

2
Advertisement
2
2
2015-10-23 02:03:00 +0000
Advertisement

我在CentOS中遇到了KERN\DIR错误。查看了shell安装脚本,发现它将KERN/DIR设置为/usr/src/kernels。然后用 “uname -r "显示我运行的内核版本比/usr/src/kernels下的源代码低。

我查看了/boot/grub/menu.lst……并确认了内核不匹配。很奇怪。

所以修复方法是…… "yum -y update kernel",然后重启。然后安装了VMWare工具。

2
2
2
2013-05-28 18:05:47 +0000

@hhh 你应该只搜索linux-headers,找到适合你架构的好的。在我的例子中

# aptitude search linux-headers      
v linux-headers -                                                                              
p linux-headers-2.6-amd64 - Header files for Linux amd64 configuration (dummy package)                   
p linux-headers-3.2.0-4-all - All header files for Linux 3.2 (meta-package)                                
p linux-headers-3.2.0-4-all-amd64 - All header files for Linux 3.2 (meta-package)                                
i A linux-headers-3.2.0-4-amd64 - Header files for Linux 3.2.0-4-amd64                                         
i A linux-headers-3.2.0-4-common - Common header files for Linux 3.2.0-4                                        
p linux-headers-3.2.0-4-common-rt - Common header files for Linux 3.2.0-4-rt                                     
p linux-headers-3.2.0-4-rt-amd64 - Header files for Linux 3.2.0-4-rt-amd64                                      
i linux-headers-amd64 - Header files for Linux amd64 configuration (meta-package)                    
p linux-headers-rt-amd64 - Header files for Linux rt-amd64 configuration (meta-package)

所以,在我的情况下,我有一个64位架构,我必须安装linux-headers-amd64

还有一点就是apt-get add不存在。用apt-get代替apt-key

1
Advertisement
1
1
2014-06-08 02:10:33 +0000
Advertisement

试试

yum install kernel* dkms gcc

然后

yum install kernel-uek-devel

然后重启你的机器。

0
0
0
2016-06-08 16:03:37 +0000

这个错误意味着vboxdrv/vboxadd找不到你的内核源。

脚本期望/lib/modules/$(uname -r)/build文件夹指向/usr/src/kernels/$(uname -r),而kernelrelease文件夹应该有Makefile,它可以在那里执行uname -r任务,所以它可以与你当前安装的内核版本(0x6&)进行比较。

所以如果这个命令失败了。

make -C /usr/src/kernels/$(uname -r)/build kernelrelease

你应该通过以下方式安装Linux头文件:

sudo apt-get install linux-headers-$(uname -r)

更多细节,请查看这个 帖子 .

0
Advertisement
0
0
2016-06-22 11:47:51 +0000
Advertisement

对于任何一个操作系统,你都需要确保所有需要的软件包都安装好了。在我的例子中,在Debian上我缺少dkms和linux-headers-generic这两个包。

#apt-get install dkms build-essential linux-headers-generic linux-headers-$(uname -r)

完整的说明请看这个 VirtualBox 论坛帖子 .

Advertisement

相关问题

12
11
8
5
17
Advertisement
Advertisement