Automating VMWare Tools reconfiguration | arfore dot com

One of the pains that come with kernel updates in Linux is the necessity to rebuild vendor kernel modules or custom written kernel modules.

As time goes by many vendors are adding support for the Dynamic Kernel Module Support (DKMS) framework.  Recent releases of both the ATI Catalyst and the NVIDIA drivers support DKMS at some level.  VMWare is currently exploring this and you can turn it on (if you have DKMS support installed) however, it is still marked as experimental.

On my production servers we don’t encourage widespread use of experimental features so this has not been enabled with the VMWare Tools installation.  Unfortunately this means that during the patching process it is possible to lose network connectivity due to the need to rebuild the VMWare Tools configuration after a kernel update.

I found one solution to this on the LinuxDynasty site.  The problem with this particular method is that the file that is being checked for “not_configured” only gets written in a small set of circumstances.  In my case, the VM was partially configured, so this file wasn’t written.

Here is my alteration of the solution linked to above.

Update the code in the vmware-tools startup script

In the following file:

Add the following line after the vmblockfusemntpt variable declaration

rebuild_tools=”/etc/vmware-tools/rebuild_needed”

Then add the following line in the end of the start case for the service (around line 1370)

Add the check code to the rc.local startup script

In the file

Add the following to the end of the file

 rkernel=`uname -r`
if [ -e /etc/vmware-tools/rebuild_needed ]; then
echo “vmware-tools not configured for running kernel $rkernel”
echo “running vmware-config-tools.pl”
/usr/bin/vmware-config-tools.pl -d
echo “vmware-tools now compiled for running kernel $rkernel”
echo “restarting vmware-tools”
/etc/init.d/vmware-tools restart
echo “vmware-tools restarted”
echo “restarting networking”
/etc/init.d/network restart
echo “network restarted”
rm /etc/vmware-tools/rebuild_needed
exit 0
fi

Now the next time you reboot your Linux box after updating the kernel, the vmware tools will be properly reconfigured and the appropriate services restarted automatically.