Wednesday 15 June 2011

Installing Linux VMWare Tools on Ubuntu

Infrequently, I create a new VMWare Linux VM. I do this just infrequently enough that I can't quite remember the procedure for installing VMWare Tools to the VM. This is documented in lots of places, I'm sure, and I normally try to stay away from repetition of readily available material… but I can never find it when I want it. So, as an aide memoire to myself and (hopefully) a handy reference for anyone else who needs to go through the procedure, here are the necessary steps on Ubuntu. I'm using Ubuntu Server 11.04 (with no GUI) but the steps should work on other versions (including desktop versions if you open a terminal: the instructions assume you have a shell open already).

Many of the steps here will be obvious to most users, but I've detailed everything so you can (if you wish) just copy and paste the lot (almost - see the notes) into shell scripts which will get the job done quicker. And those just starting out will also have a reference they can use.
  1. [Optional] Change the kernel. Even with the server install I did to write this article, the generic kernel was installed by default even though a kernel optimised for server operations is available. Not only that, but there is a version of the server kernel trimmed down to have only what is necessary for use in common virtualised platforms, including VMWare
  2. # Install latest kernel version
    sudo aptitude update
    sudo aptitude install linux-virtual
    
    # Reboot, so the new kernel is running when the tools
    # package is built and the correct headers will be
    # selected in step 3
    sudo shutdown -r now
    
  3. Attach the Tools ISO to the VM. In vSphere Client, you can right-click the VM in the inventory and select Guest -> Install / Upgrade VMWare Tools
  4. Install tools, with necessary packages (I'm assuming you are starting in your home folder or somewhere equally appropriate for putting the tools installation directory)
    # Most commands need root access. You can use 'sudo'
    # where necessary instead
    sudo su
    
    # Update apt package database (if you didn't earlier)
    aptitude update
    
    # Install packages necessary to build tools
    aptitude install build-essential linux-headers-`uname -r`
    # note backticks around uname command, not ordinary
    # inverted commas
    
    # No suitable mount point existed in my default install:
    # create one
    mkdir /media/dvd
    
    # Mount tools image and extract tarball
    mount /dev/dvd /media/dvd
    tar -xzf /media/dvd/VMwareTools-*.tar.gz
    # You can use auto-complete above: it's just one file
    
    # Run install script
    cd vmware-tools-distrib/
    ./vmware-install.pl -d  # -d auto-accepts all defaults
    
    # Tidy up and exit root shell
    cd ..
    rm -rf vmware-tools-distrib/
    umount /media/dvd  # the script usually does this for you
    exit
    
Notes
  1. The kernel headers are installed by default on Ubuntu, so the linux-headers-* package is only necessary if the kernel has been changed since installation.
  2. The "uname" command in the install list ensures that the package for the running kernel is selected. If you've just installed a kernel using one of the metapackages listed above, it will be the latest one and headers can be installed simply with "linux-headers-virtual" (for example).
  3. To initialise the tools, the "/etc/bin/vmware-config-tools.pl" script needs to be run. If you used '-d' or allowed the script to run this itself (it prompts for this in interactive mode), this will already have been done, but it can be useful to know about this separate step in case of problems.
  4. If you put the second set of commands into a script, you'll need to remove "sudo su" from the start and run the script as root. "su" opens a new shell and the commands from the rest of the script will not be passed into it if you run as-is.
Once the tools are installed, updates can be performed automatically from the host so there is rarely a need to refer back to this process for an existing machine

No comments:

Post a Comment