This feature is disabled by default, because it reduces performance by a small but measurable amount. If you query the virtual machine configuration, you can determine if it is capable of changed block tracking. Use the property collector to retrieve the capability field from the VirtualMachineManagedObject. If the capability field contains the flag changeTrackingSupported, then you can proceed. The virtual machine version must be 7 or higher to support this. If the virtual machine version is lower than 7, upgrade the virtual hardware.

If supported, you enable changed block tracking using an abbreviated form of VirtualMachineConfigSpec, then use the ReconfigVM_Task method to reconfigure the virtual machine with changed block tracking:

VirtualMachineConfigSpec configSpec = new VirtualMachineConfigSpec();
configSpec.changeTrackingEnabled = new Boolean(true);
ManagedObjectReference taskMoRef =
    serviceConnection.getService().ReconfigVm_Task(targetVM_MoRef, configSpec);

Powered-on virtual machines must go through a stun-unstun cycle (triggered either by power on, migrate, resume after suspend, or snapshot create/delete/revert) before the virtual machine reconfiguration takes effect.

To enable changed block tracking with the vSphere Client:

  1. Select the virtual machine and ensure that Summary > VM Version says “7” or higher compatibility.
  2. In the Summary tab, click Edit Settings > Options > Advanced > General.
  3. In the right side of the dialog box, click Configuration Parameters...
  4. In the new dialog box, locate or create a row with name ctkEnabled, and set its value to true not false. See above concerning the stun-unstun cycle.

To enable changed block tracking and back up with the VMware vSphere API:

  1. Query change tracking status of the virtual machine. If false, activate changed block tracking.
    configSpec.changeTrackingEnabled = new Boolean(true);
  2. Create a snapshot of the virtual machine. The snapshot operation causes a stun-unstun cycle.
    CreateSnapshot_Task(VMmoRef, SnapshotName, Description, memory_files, quiesce_filesystem);
  3. Starting from the snapshot’s ConfigInfo, work your way to the BackingInfo of all virtual disks in the snapshot. This gives you the change IDs for all the disks of the virtual machine.
  4. Hold onto the change IDs and do a full backup of the snapshot, since this is the first time for backup.
    VixDiskLib_Read(snapshotDiskHandle, startSector, numSectors, &buffer); /* C not Java */
  5. Delete the snapshot when your backup has completed.
    removeSnapshot_Task(SnapshotName, Boolean FALSE);
  6. Next time you back up this virtual machine, create a snapshot and use QueryChangedDiskAreas with the change IDs from your previous backup to take advantage of changed block tracking.
    changes = theVM.queryChangedDiskAreas(SnapshotMoRef, diskDeviceKey, startPosition, changeId);