When you install a new kernel on a RHEL/CentOS VM, you need to reconfigure the vmware-tools using the 'vmware-config-tools.pl' script. I have created a simple script that does this automagicalliy, so you don't have to be there when the kernel is updated (handy for automatically updating machines).
Place this in a script called 'check-vmware-tools' in /etc/init.d:
#!/bin/bash
#
# check-vmware-tools
#
# chkconfig: - 00 99
# description: Check whether or not the vmware-tools are installed at boot time.
# processname: check-vmware-tools
#
loadvmxnet() {
/sbin/rmmod pcnet32
/sbin/rmmod vmxnet
/sbin/depmod -a
/sbin/modprobe vmxnet
}
case $1 in
start)
echo -n $"Checking VMware-tools: "
if [ ! -e /lib/modules/`/bin/uname -r`/misc/vmci.ko ]; then
echo "Not available, running vmware-config-tools..."
/usr/bin/vmware-config-tools.pl --default && loadvmxnet
else
echo "OK"
fi
;;
*)
echo "Usage: $0 start"
exit 1
;;
esac
Make it writeable with 'chmod +x /etc/init.d/check-vmware-tools'.
Next is to make it known by chkconfig with 'chkconfig --add check-vmware-tools'.
Now we have done that, we can simply enable it with 'chkconfig check-vmware-tools on'.
On the next boot, this script checks whether or not the vmware-tools are configured for the running kernel (by checking if vmmemctl.ko is in place). If not, it runs 'vmware-config-tools.pl and reboots after that.
Hope you like it. :-)
Small updates, 23/12/2009:
- It might be a better idea to just check for the vmxnet driver instead of the ballooning driver which you might not even use. Changed vmmemctl.ko to vmxnet.ko.
- In the previous version, it rebooted after running vmware-config-tools.pl. This has now changed to simply loading the vmxnet driver.
Some people might have noticed that vmware-config-tools.pl builds a new initrd-image. The only thing that is changed in that initrd-image is the vmxnet driver that had been added. This is probably to make sure the OS doesn't load the pcnet32 driver. A reboot is not necessary.