virtualbox安装centos 6 增强工具提示“Unable to find the kernel source tree for the currently running kernel”

万嘉熙
2023-12-01

 virtualbox安装centos 6之增强工具时,在错误日志中会提示:unable to find the source of your current linux kernel


#sudo sh ./VBoxLinuxAdditions.run 

提示失败 

Building the VirtualBox Guest Additions kernel modules [FAILED] 
Your system does not seem to be set up to build kernel modules. 
Look at /var/log/vboxadd-install.log to find out what went wrong. 
Once you have corrected it, you can run /etc/init.d/vboxadd setup to build them. 

#gedit /var/log/vboxadd-install.log 内容 

Makefile:23: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.. Stop. 
Creating user for the Guest Additions. 
Creating udev rule for the Guest Additions kernel module. 

安装GCC 

#yum install gcc 

# yum install gcc kernel-devel kernel-headers 

重启。 

再次安装VBoxLinuxAdditions,OK。


注意需要以Root身份运行,否则会提示权限不够。



即便按此操作依旧安装失败。继续找原因。

需要设置KERN_DIR环境变量

好吧,安装的KERN版本为2.6.32-358.23.2.el6.x86_64,但不知为何系统变量即使设置为如上目录,Linux依旧寻找这个版本

2.6.32-358.el6.x86_64


试着将它复制一份,到2.6.32-358.el6.x86_64目录,再次运行,安装成功。!

 类似资料: