清单 2 中所示输出的日志文件 /var/log/vboxadd-install.log 指示问题在于缺少内核资源:
# more /var/log/vboxadd-install.log
/tmp/vbox.0/Makefile.include.header:94: *** Error: unable to find the sources of your
current Linux kernel. Specify KERN_DIR=<directory> and run Make again. Stop.
在 Fat Bloke 博客的帮助下,我确认了问题的根源。Oracle Linux 自带了两个内核:一个是与 Red Hat 100% 兼容的,另一个是 Unbreakable Enterprise Kernel (UEK)。我的 Linux 来宾运行的是 UEK,因此需要安装相应的gcc 和 kernel-uek-devel 程序包,以便 Guest Additions 安装能够正常工作。这是因为 Guest Additions 安装需要构建和安装内核驱动程序。我使用了以下yum install 命令来下载和安装缺少的程序包:
# yum update
# yum install gcc
# yum install kernel-uek-devel (yum output not shown)