Skip to content

Update VMware tools before reboot

I have searched the web and couldn't think of a simpler way to do this.

When you upgrade your kernel, all modules that were installed by the VMware tools will be missing in the new /lib/modules directory. To reinstall those, you need to reboot first and then re-run the VMware tools. Problems arise if you need the modules prior to the next reboot (ie: if you are doing weird pvscsi on root partition for example).

Out of the box, the VMware tools cannot regenerate modules and initrd for a kernel different than the running one. If you are upgrading the same distribution to a different patch level (RHEL 5 system to a bugfix kernel), chances are that the same modules will work, you just have to install them at the new location.

Tricking the VMware tools software into installing some place else works very well in that case.

This snippet is very RedHat specific, but could be adjusted for any distro. Main points include the uname hack, running a depmod and rebuilding initrd image.

It is important to note that the tools do run depmod, but not specifying a kernel version, hence defaulting to the running kernel.


# Get latest kernel installed
VERSION="$(rpm -qa kernel | sort -r | head -n 1 | sed 's/kernel-//')"

# uname hack (because VMware Tools are stupid)
mv /bin/uname{,.orig} &&
cat > /bin/uname << EOF &&
#!/bin/sh
exec /bin/uname.orig "\$@" | sed 's/2.6.[^ ]*/${VERSION}/'
EOF
chmod 0755 /bin/uname

# Launch VMware Tools install
/usr/bin/vmware-config-tools.pl -d

# Remove our uname hack
mv /bin/uname{.orig,}

# Redo what VMware missed
depmod -a $VERSION
mkinitrd -f /boot/initrd-$VERSION.img $VERSION


Tested on RHEL 5.4 upgrading to a security fix kernel, works like a charm.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

Add Comment

Form options