Vmware Server最新版本2.0.2-203138是在2009年发布的,其使用一种较老的Kernel识别方法,这会导致我们在2.6.3x/2.6.40内核上安装Vmware Server时出现如下错误:
The path "/usr/src/linux/include" is not an existing directory.
The directory of kernel headers (version @@VMWARE@@ UTS_RELEASE) does not match
your running kernel (version 2.6.40-4.fc15.x86_64). Even if the module were to
compile successfully, it would not load into the running kernel.
摸索了1个多小时终于找到了解决的方法,具体步骤如下:
1.安装必要的rpm包
yum -y install gcc make kernel-headers kernel-devel
找出正确的kernel headers目录,使用如下命令:
[root@vbase include]# echo /usr/src/kernels/`uname -r`/include
/usr/src/kernels/2.6.40-4.fc15.x86_64/include
2.修改version.h头文件,该文件位于以下目录
[root@vbase include]# cat /usr/src/kernels/`uname -r`/include/linux/version.h
#define LINUX_VERSION_CODE 132648
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
在该头文件中加入 uname -r的输出,如:
[root@vbase include]# uname -r
2.6.40-4.fc15.x86_64
#define UTS_RELEASE "2.6.40-4.fc15.x86_64"
3.下载modules.tar文件,解压该tar包,将其中的文件复制到/usr/lib/vmware/modules/source/并覆盖:
tar -xvf modules.tar
cp * /usr/lib/vmware/modules/source/
cp: overwrite `/usr/lib/vmware/modules/source/vmblock.tar'? y
cp: overwrite `/usr/lib/vmware/modules/source/vmci.tar'? y
cp: overwrite `/usr/lib/vmware/modules/source/vmmon.tar'? y
cp: overwrite `/usr/lib/vmware/modules/source/vmnet.tar'? y
cp: overwrite `/usr/lib/vmware/modules/source/vsock.tar'? y
4.安装Vmware软件,并执行vmware-config.pl
[root@vbase include]# vmware-config.pl
Making sure services for VMware Server are stopped.
Stopping vmware (via systemctl): [ OK ]
None of the pre-built vmmon modules for VMware Server is suitable for your
running kernel. Do you want this program to try to build the vmmon module for
your system (you need to have a C compiler installed on your system)? [yes] yes
Using compiler "/usr/bin/gcc". Use environment variable CC to override.
What is the location of the directory of C header files that match your running
kernel? [/lib/modules/2.6.40-4.fc15.x86_64/build/include]
Extracting the sources of the vmmon module.
Building the vmmon module.
Using 2.6.x kernel build system.
make: Entering directory `/tmp/vmware-config2/vmmon-only'
make -C /lib/modules/2.6.40-4.fc15.x86_64/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. \
MODULEBUILDDIR= modules
make[1]: Entering directory `/usr/src/kernels/2.6.40-4.fc15.x86_64'
CC [M] /tmp/vmware-config2/vmmon-only/linux/driverLog.o
CC [M] /tmp/vmware-config2/vmmon-only/linux/iommu.o
CC [M] /tmp/vmware-config2/vmmon-only/linux/driver.o
CC [M] /tmp/vmware-config2/vmmon-only/linux/hostif.o
/tmp/vmware-config2/vmmon-only/linux/hostif.c: In function ‘HostIFReadUptimeWork’:
/tmp/vmware-config2/vmmon-only/linux/hostif.c:2048:10: warning: ‘newUpBase’
may be used uninitialized in this function [-Wuninitialized]
CC [M] /tmp/vmware-config2/vmmon-only/common/memtrack.o
CC [M] /tmp/vmware-config2/vmmon-only/common/hashFunc.o
CC [M] /tmp/vmware-config2/vmmon-only/common/vmx86.o
CC [M] /tmp/vmware-config2/vmmon-only/common/cpuid.o
CC [M] /tmp/vmware-config2/vmmon-only/common/task.o
CC [M] /tmp/vmware-config2/vmmon-only/common/comport.o
CC [M] /tmp/vmware-config2/vmmon-only/common/phystrack.o
CC [M] /tmp/vmware-config2/vmmon-only/vmcore/moduleloop.o
LD [M] /tmp/vmware-config2/vmmon-only/vmmon.o
Building modules, stage 2.
MODPOST 1 modules
CC /tmp/vmware-config2/vmmon-only/vmmon.mod.o
LD [M] /tmp/vmware-config2/vmmon-only/vmmon.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.40-4.fc15.x86_64'