Command-line backup for VMWare Fusion Virtual Machines

If you have a bunch of VMWare Fusion virtual machines running, you can suspend them programmatically using vmrun and rsync them to a mounted volume. Then, with the copy completed, you can resume the virtual machines.

#!/bin/bash

BACKUPDIR=/Volumes/Backup/VMs

/Library/Application\ Support/VMware\ Fusion/vmrun list | tail -n +2 | while read VM
do
  echo "Suspending $VM"
  time /Library/Application\ Support/VMware\ Fusion/vmrun -T fusion suspend "$VM"
  echo "Suspended $VM"
  
  DIR=`dirname "$VM"`
  echo "Rsyncing $DIR"
  rsync -av "$DIR" "$BACKUPDIR"
 
  echo "Resuming $VM"
  time /Library/Application\ Support/VMware\ Fusion/vmrun -T fusion start "$VM"
  echo "Resumed $VM"
done

Note: this hung on Windows VMs until I updated VMWare Tools to the latest version on the guest. The above is currently working on Fusion 3.1 for RHEL5 and Windows 2008 R2 Server guests.

[ Submitted by John on Tue, 2010-06-08 14:28. | | ]

Solution to 100% CPU Usage by Linux Guest on VMWare Fusion

As part of my testing setup, I have an Intel Mac Pro with Mac OS X 10.6 Server (which runs with the 64-bit kernel) on which I run VMWare Fusion 3.0.1 and several Red Hat virtual machines.

I noticed that even at idle, each VM was taking up a high amount (like 100%!) of a CPU core. Additionally, on one VM top was displaying in near-real-time, which was kind of neat but I doubt the intended behavior. Because of this, I suspected the time management in the kernel was off.

Sure enough, Timekeeping Best Practices for Linux Guests has some hints, and for more information than you'll ever want, try Timekeeping in VMWare Virtual Machines (I was particularly interested in the Clocksource Kernels section).

Making the following modification to /etc/grub.conf on RHEL5 brought my CPU usage down from 100% to barely noticeable:

Before:

kernel /vmlinuz-2.6.18-164.11.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet

After:

kernel /vmlinuz-2.6.18-164.11.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb divider=10

I took out quiet because I like to see what's happening when the system boots.

The Note on RHEL 5.4 or CentOS and divider=10 mentions that you do not need this for RHEL 5.4 for accurate timekeeping, but you do need it to prevent the excessive CPU use.

I also modified /etc/ntp.conf as described in the above article, adding

tinker panic 0

to the top of the file and commenting out the following lines:

# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
#server 127.127.1.0
#fudge 127.127.1.0 stratum 10

My VMs are down from 100 percent CPU use to practically zero. Think of the energy savings!

[ Submitted by John on Fri, 2010-02-12 11:35. | | ]