Get My Podcast On iTunes!
Badges

vexpert_logo_100x57

gestaltitbadge

follow-me-twitter

Subscribe to me on FriendFeed

Comments / DISQUS
Feedjit.com

Automating VMware Tools Installs and Upgrades in Linux Guests

Last week I had a customer ask me for help with a repetitive administrative task that is extra aggravating for shops with a lot of Linux virtual machines (VMs). The customer was frustrated with the manual process of upgrading VMware Tools after kernel upgrades in their VMs. It’s a problem unique to Linux since the Windows operating system kernel does not change very frequently, but the development cycle of several Linux distributions can mean multiple kernel versions each year. After each upgrade and subsequent VM reboot the VMware tools must be re-installed so the tools are compiled correctly with the new kernel. Not exactly fun to do when you have a lot of Linux VMs.

I suggested 2 alternatives for the customer. The first is a scripted solution configured inside each Linux VM and the second is a built in feature of VirtualCenter and ESX for versions 2.0.1 and 3.0.1 or greater. I have not tested either of these solutions. My reason for writing this post is partly to explain the options, but also to get some feedback from the community. Let me know if you use or have tried either of these solutions or anything similar. If there is a better way please comment on this post! If you try one of these for your Linux virtual guests let me know what works and what doesn’t.

The following methods require that VMware tools are already installed in the Linux guests. For instructions for installing the tools check out the current VMware .pdf guide titled Basic System Administration Update 2 Release for ESX 3.5, ESXi version 3.5, VirtualCenter 2.5. if you are wondering if you should even install VMware tools in Linux guests than check out my post “Why do I need to install VMware Tools?”.

Script to detect Linux kernel change and re-install VMware tools

I stumbled across this script from the post Automating VMware modules reinstall after Linux kernel upgrades – From the Recliner…

“Now, most admins note about the “–default” option which can be used when running the vmware-config-tools.pl (or vmware-config.pl) script to cause the script automatically answer all the questions with the default answer. All we need is a way to run this automatically when a new kernel is booted. It turns out, at least with Redhat systems (and I suspect other systems), that this is exceptionally easy. For legacy reasons the Redhat init scripts check for the existence of a file called /etc/rc.modules and, if it exist, execute it. The file is typically a simple shell script and thus all we need is a simple method for detecting if the currently booting kernel already has the VMware modules installed and, if not, run the vmware config script with the “–default” option.

Here’s the script that I’m currently using with Linux VM’s running in VMware ESX/Server:

#!/bin/bash

if [ ! -e /lib/modules/`uname -r`/misc/.vmware_installed ]; then
/usr/bin/vmware-config-tools.pl –default
touch /lib/modules/`uname -r`/misc/.vmware_installed
fi

Simply place these lines in /etc/rc.modules and make sure it is executable and your good to go. Note that it’s possible you may already have a rc.modules file so in that case you should just add the lines to the existing file. When you install a new kernel and reboot the “.vmware_installed” file will be missing from the /lib/modules directory for that kernel and it will run the vmware-config-tools.pl (or vmware-config.pl) with the “–default” option to reinstall the VMware kernel modules. Even better, because this is called very early during startup, long before the VMware services are started, eveything will work the first time with no interaction whatsoever.

One thing to look out for, if you install an upgraded vmware-tools (or VMware Workstation/Server release) without upgrading the kernel and you want the new modules to be installed on the next reboot you need to remove the “.vmware_installed” file. Simply run the following command and the new modules will be installed on the next boot:

rm -f /lib/modules/`uname -r`/misc/.vmware_installed

One major drawback, if your system uses a separate partition/logical volume for /usr, which is common, then the rc.modules script will probably be called before that system is mounted. Possible solutions include adding a command to mount /usr at least read-only before attempting to run the vmware-config script or, you could just move the commands to rc.local. The disadvantage of rc.local is that, for Linux guest VM’s using the “flexnet” adapter they will have already loaded the pcnet32 module in place of the vmxnet driver. You could easily script unloading this module and restarting the vmware-tools service, but I’ve seen a few applications that behave poorly if you stop networking after they’ve already been started.

The concept of this solution is solid. If would recommend that you create a gold image template with the script already configured and deploy new VMs from this template. I imagine that slight variances in the script benefit different distributions. Read the entire post and it’s comments at the link above for some additional advice and user feedback.

Use the VI Client to update VMware Tools in multiple VMs simultaneously

The built in feature of VirtualCenter and ESX to bulk upgrade VMware tools works great for Windows VMs. VMware’s documentation confirms the process works for supported Linux guests as well. For a table of all supported guest operating systems go here.

Here are the step by step instructions for using the VI Client:

  1. Launch the VI Client and log in to the VirtualCenter Server.
  2. Click Inventory in the navigation bar and expand the inventory.
  3. In the inventory list, select the host on which virtual machines you want to upgrade reside.
  4. Click the Virtual Machines tab.
  5. Select the virtual machines you want to upgrade with the new version of VMware Tools.
  6. Right?click the virtual machines and choose Install/Upgrade Tools.

VirtualCenter provides two options to upgrade VMware tools:

  • Interactive tools upgrade - Requires some user interaction and requires you to reboot the guest operating system manually.
  • Auto tools upgrade – Upgrades tools without user interaction and reboots the guest operating system, if required. Auto tools upgrade is supported for tools version ESX 3.0.0 and above on Windows and Linux guest operating systems.
  • Note: the field for Advanced Options can use any of the command line options

Command line options:

Option
Description
-u user Specifies a user with sufficient privileges on the target virtual machine, including VirtualMachine.Config.*, VirtualMachine.Interact.*, and VirtualMachine.Provisioning.*
-p password Specifies a password on the command line. If this is omitted, the tool immediately prompts for a password.
-n vmname Specified the name of the virtual machine to upgrade. This name corresponds to the display name of a virtual machine. Specify multiple virtual machines using multiple -n parameters. The -n option is ignored if -h is specified.
-h host Attempts to upgrade all the virtual machines on a particular host. Fails if the specified host is not version ESX Server 3.0 or greater.See
-m maxpowerons On a particular host, powers on only this number of virtual machines at a time.
-o port Specifies the VirtualCenter Server port, if a port other than the default port 902 has been configured.
-t maxpowerontime Allows a user to set the maximum amount of time for a virtual machine to be powered on in case the guest is unable to power off the machine itself.After the tools upgrade is scheduled on a virtual machine, the virtual machine is powered on and allowed to run through the tools installation process. In most cases, the guest powers down the machine automatically when the process completes.
-s Skips the tools and does only the virtual hardware upgrade.
-q Works quietly. Doesn’t produce status or completion messages on stdout.

For more information about bulk upgrading VMware Tools and using the VirtualCenter command line as an alternative see my previous post Use the VI Client to bulk upgrade VM tools.

VMworld 2008 Session for VMware in a Linux Shop

If you are attending VMworld 2008 next month the session listed below may provide complimentary recommendations for managing Linux VMs. The presenter, Mike DiPetrillo, maintains his own blog titled From the VMware Field: Mike D’s Virtualization Blog and is a fellow resident of Atlanta, GA. Check out both Mike’s blog and his session if you can. I have a schedule conflict but will keep this session on my “preferred switch list”. If you are reading this and VMworld 2008 was in the past look up the presentation at VMworld.com. (It feels weird writing a message for someone in the future!)

PO2575 Deploying VMware in a Linux Shop Breakout
Mike DiPetrillo
Principal Systems Engineer,
VMware, Inc.
Session Title: Deploying VMware in a Linux Shop
Length: 1 Hour
Level: Intermediate
Abstract: Are you a Linux shop? Come learn how well
VMware fits into your existing environment. Learn how to integrate
VMware with your existing monitoring and management platforms. Learn
how to tweak VMware to get the best performance possible. Find out what
VMware is doing with paravirtualization. Learn what applications to run
in a virtual machine. See live demos on what you can and can’t manage
in a VMware environment from 3rd party Open Source tools.
Speaker: Mike DiPetrillo

Principal Systems Engineer

VMware, Inc.

Related Posts

View Comments to “Automating VMware Tools Installs and Upgrades in Linux Guests”

  • phiney says:

    I use the /lib/modules/`uname -r`/misc/.vmware_installed flag method in a init.d script that i call check_vmware_tools. it works really quite well. for best results, make sure parallel boot processing is OFF. This allows the for vmware-config-tools.pl to finish and the check_vmware_tools script to restart your network before your vital services start (eg apache, dns, oracle, etc). If you can't do this, then have the check_vmware_tools script reboot after the vmware-config-tools.pl.

    ph

  • rbrambley says:

    Phiney,

    Thanks for your adding your experience upgrading the Tools in Linux VMs!

  • Tom says:

    Does this work for Linux VMs under ESX 3.5 U6??
    I tried the right-click method and cannot tell if it works or not…
    Thank you, Tom

  • “Well , the view of the passage is totally correct ,your details mbt shoes store is really reasonable and you guy give us mbt shoes valuable informative post, I totally agree the standpoint of upstairs. I often surfing on this forum when I m free and I find there are so much good information we can learn in this forum!

  • coach outlet says:

    “Well , the view of the passage is totally correct ,your details is really reasonable and you guy give us valuable informative post, I totally agree the standpoint of upstairs. I often surfing on this forum coach outlet when I m free and I find there are so coach handbags much good information we can learn in this forum! ugg boots

Leave a Reply

blog comments powered by Disqus
Support VM /ETC
Support VMETC.com

Support VMETC.com

Free Business and Tech Magazines and eBooks
@rbrambley tweets
VMTN Roundtable Podcasts
Subscribe



Add to Google Reader or Homepage
Subscribe in NewsGator Online
Add to netvibes
Add to Plusmo