I came across this site when researching a way to automatically get the VMware tools re-installed on kernel updates.
There were plenty of comments but it seemed everybody had a different way of implementing how and when the script to update gets called. Plus, as there are so many init variations amongst the distributions, some SuSe stuff would not work on Red Hat.
Anyway, I have implemented yet another solution for Red Hat / CentOS. (I’m using 5.3).
I pinched this script from the very bottom of the site on tuxy.turvy.com.
#! /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
Save the above as file on your server called vmware-check-tools. Then do the following as root.
# cp vmware-check-tools /etc/init.d
# chmod 755 /etc/init.d/vmware-check-tools
# cd /etc/rc.d/rc3.d
# ln -s ../init.d/vmware-check-tools S09vmware-check-tools
All Done ! That is a zero-nine BTW. S09. If you look in that rc3.d directory, you will notice lots of scripts starting with S and K and various numbers after them. This is how the init system starts/stops processes and in which order. We want the module check script to run before the network starts (so we load the vmxnet module). The network script is listed as S10network. So, I chose s09vmware-check-tools so it would run immediately before the network starts.
This actually works and I’ve rolled it out to all my CentOS boxes. There is no need for a K script as we don’t need to run the script when the server shuts down.
What the script does is check the current kernel misc module directory for the file, ‘.vmware_installed’. If it does not find it, vmware-config-tools.pl will be run with the default flag and then the .vmware_installed file will be created so the tools won’t re-install next boot (on the same kernel).
With the above, I’m only looking after runlevel 3. That is, boot to the prompt. If you are one of those people who feel more secure booting to X windows, that would mean you are in runlevel 5. (Check /etc/inittab). In that case, you would want to create the symbolic link S09vmware-check-tools in the rc5.d directory.
Cheers
Pingback: How to reinstall vmware tools after kernel update : HB blog
#1 by Kevin on March 19, 2012 - 10:49 pm
Very helpful! Thank you! The symbolic link command seems to be incorrect. The following should work:
“ln -s /etc/init.d/vmware-check-tools /etc/rc.d/rc3.d/S09vmware-check-tools”
#2 by David on April 13, 2012 - 11:37 pm
I was working from the cwd dude!
On top of that, I’m a complete dunce. Of course you are correct. I’ve updated the post.
#3 by Michael on May 30, 2012 - 10:05 pm
In case its useful for anyone else on CentOS6.2 when i used the command # ln -s ../init.d/S09vmware-check-tools it would create a (broken) link called S09vmware-check-tools to a file called init.d/S09vmware-check-tools not init.d/vmware-check-tools and when booting the CentOS vm i would get a message vmxnet3 not initialised using the command provided by #1 Kevin worked for me.
Thanks for putting together the post and script vmadmin Its a great help
#4 by Gary on October 9, 2012 - 7:39 am
Where did you get this file ?
VMToolsCheckFile=”/lib/modules/`uname -r`/misc/.vmware_installed”
I have looked in every kernel dir and I dont see any file called .vmware_installed.
I am running RHEL 5.7.
Thanks,
Gary
#5 by David on October 12, 2012 - 12:08 pm
Hi,
The .vmware_installed file gets created the first time the script is run. It is a way for the script to know that the VM tools have been run for the current kernel.
If you updated the kernel, there would be no .vmware_installed file and therefore the vmware-tools script would get re-run.
Cheers
#6 by Benny on November 29, 2012 - 10:23 pm
Hi,
Many thanks for this. Our RHEL farm has grown to about 50 virtuals this year so this is a big help.
Confirmed the above worked on a RHEL 5.9 Virtual for the latest kernel update.
Cheers