Probably most of you already had to log in the VMWare console to reinstall vmware tools after kernel update.

Usually we do that by simply running:

/usr/bin/vmware-config-tools.pl

After doing it few times I’ve decided to find an automated way of doing it. After quick search on Internet I found an article giving acceptable solution to my problem.

I’ll share the solution here (with two small fixes 😉 as bonus).

– Open terminal and create new file

vi /etc/init.d/vmware-check-tools

– Paste following inside:

#!/bin/bash
# Following lines auto-recompile VM Tools when kernel updated
VMToolsCheckFile="/lib/modules/`uname -r`/misc/.vmware_installed"
VMToolsVersion=`vmware-config-tools.pl --help 2>&1 | awk '$0 ~ /^VMware Tools [0-9]/ { print $3,$4 }'`

printf "\nCurrent VM Tools version: $VMToolsVersion\n\n"

if [[ ! -e $VMToolsCheckFile || `grep -c "$VMToolsVersion" $VMToolsCheckFile` -eq 0 ]]; then
[ -x /usr/bin/vmware-config-tools.pl ] && \
printf "Automatically compiling new build of VMware Tools\n\n" && \
/usr/bin/vmware-config-tools.pl --default && \
printf "$VMToolsVersion" > $VMToolsCheckFile && \
rmmod pcnet32
rmmod vmxnet
depmod -a
modprobe vmxnet
fi

Then make it executable:

chmod 755 /etc/init.d/vmware-check-tools

And finally create symlink:

cd /etc/rc.d/rc3.d
ln -s ../init.d/vmware-check-tools S09vmware-check-tools

Comments

One Response to “How to reinstall vmware tools after kernel update”

  1. Martin Stolpe on November 27th, 2012 11:56 am

    Really nice script. Thanks a lot!

Leave a Reply

You must be logged in to post a comment.