Tweaking VMware Workstation for Performance

From Nearline Storage
Jump to: navigation, search
  1. Add "vmem" and "vmdk" extensions for your Linux antivirus software's exclude list. (This means the underlying host system's antivirus software, not what you may be running in the VMware image itself.)
  2. Move the memory backing file to RAM.

Adding extensions to Symantec Corporate Edition's exclude lists

I created a script which I ran specifying "vmem" and then "vmdk". This invokes the symcfg command to add each of these extension to the proper configuration keys. This only needs to be done once, or at least until something reconfigures your antivirus. Symantec keeps these changes in a local database.

#/bin/sh

#  Add specified file to Symantec Antivirus exclude lists

SYMCFG="/opt/Symantec/symantec_antivirus/symcfg"

FILETYPE="$*"
while [ -z "$FILETYPE" ]; do
  read -p "Please enter filetype to be added to the exclude list: " FILETYPE
done
FILETYPE=`echo "$FILETYPE" | tr [:lower:] [:upper:]`

function exclude-filetype () {
  KEY="$1"
  
  #  Make sure that ExcludedByExtension is turned on for this key
  VALUE="ExcludedByExtensions"
  TYPE="REG_DWORD"
  sudo "$SYMCFG" add -k "$KEY" -v "$VALUE" -d 1 -t "$TYPE"

  #  Update the list of excluded extensions for this key
  VALUE="ExcludedExtensions"
  CURRENT=`sudo "$SYMCFG" list -k "$KEY" -v "$VALUE" 2>/dev/null`
  if [ "$?" == "0" ]; then
    TYPE=`echo "$CURRENT" | sed 's/.*\s\(\w*\)/\1/'`
    CURRENT=`echo "$CURRENT" | sed 's/.*ExcludedExtensions\s\(.*\)\s.*/\1/'`
    if [ -z `echo "$CURRENT" | grep -i "$FILETYPE"` ]; then
      sudo "$SYMCFG" add -k "$KEY" -v "$VALUE" -d "${CURRENT},$FILETYPE" -t "$TYPE"
    fi
  else
    sudo "$SYMCFG" add -k "$KEY" -v "$VALUE" -d "$FILETYPE" -t REG_SZ
  fi
}

exclude-filetype "\Symantec Endpoint Protection\AV\Storages\FileSystem\RealTimeScan"
exclude-filetype "\Symantec Endpoint Protection\AV\LocalScans\ManualScan"

#  Show them what we've accomplished
sudo "$SYMCFG" -r list | grep -i exclude

Putting the vmem file back in RAM

VMware uses a vmem file in each VM's data directory as backing store for the VM's virtual memory. This file only exists while the VM is active. The IO to this file can conflict with the rest of the IO for the VM, slowing things down. So, we will move this file onto a filesystem that exists only in RAM, not on disk. This is the tmpfs filesystem. By default this filesystem has a size limit equal to 50% of your memory. You can change that with the size=xxk mount option. Best practice would be to make sure that the sum of the memory sizes of all of the VMware machines you intend to have running simultaneously does not exceed that 50% number.

  1. Add a line to /etc/fstab to place the /tmp directory on the tmpfs filesystem:
    tmpfs                  /tmp/                tmpfs   defaults        0 0
  2. Clear off the current /tmp as much as you can
  3. Reboot to mount the new /tmp and build the run time files you need on it
  4. Make sure that your VM is shut down and add
    mainMem.backing = "unnamed"
    to the VM's vmx file if you're running VMware Workstation 7 for Linux and
    mainMem.useNamedFile = "FALSE"
    if you're running anything else.

Please note that anything in your /tmp will now be deleted whenever you reboot. That's the nature of tmpfs so get used to putting your temporary stuff somewhere else from now on. (It would be nice if VMware let us tell it where to put it's vmem file so that we didn't have to use /tmp but it doesn't so we must.)