Resetting Changed Block Tracking files for VMware vSphere VMs


To totally unlock this section you need to Log-in


Login

Virtual machines running on ESX/ESXi hosts can track disk sectors that have changed. This feature is called Changed Block Tracking (CBT). On many file systems, CBT identifies the disk sectors altered between two change set IDs. On VMFS partitions, CBT can also identify all the disk sectors that are in use.

To reset CBT on a vSphere virtual machine:

  • Open the vSphere Web Client.
  • Right-click the virtual machine and click Power Off.
  • Right-click the virtual machine, click on Snapshot and navigate to Snapshot Manager. Ensure there are no active snapshots. If there are snapshots present, consolidate them to commit the changes.
  • Right-click the virtual machine and click Edit Settings.
  • Click the Options tab, select the General section and then click Configuration Parameters.
  • Disable CBT for the virtual machine by setting the ctkEnabled value to false to disable CBT for the virtual machine.
  • Disable CBT for the individual virtual disks attached to the virtual machine by setting the scsix:x.ctkEnabled value for each attached virtual disk to false. Where scsix:x is SCSI controller and SCSI device ID of your virtual disk.
  • Open the virtual machine's working directory using the Datastore Browser or ESXi shell.
  • Ensure there are no snapshot files (.delta.vmdk) present in the virtual machine's working directory.
  • Delete any -CTK.VMDK files within the virtual machine's working directory.
  • In the vSphere Web Client, right-click the virtual machine and click Power On.

If you are using a backup application which utilizes CBT you may have to manually re-enable CBT. Some backup tools will automatically enable CBT for you, check your backup vendors documentation if you are unsure.

Reset CBT on VMs using PowerCLI script

To reset CBT on multiple vSphere virtual machines using a PowerCLI script:

  • Download the attached .zip file 2139574_CBT-Reset.zip (even from HeelpBook.net, from the below download link).
  • Extract the CBT-Reset.PS1 file from the archive and save it on your local system, in an easy to remember location.
  • Install and initialize VMware PowerCLI on your local system.
  • Open VMware PowerCLI.
  • Change directory to where you saved the CBT-Reset.PS1 file by running the cd command. For example:
PowerCLI C:\> cd C:\CBTreset

Allow execution of an unsigned script by running this command:

PowerCLI C:\CBTreset> Set-ExecutionPolicy Bypass

Warning: This allows any unsigned script to run. Ensure you disable it after use.

Connect to your vCenter Server using this command:

PowerCLI C:\CBTreset> Connect-VIServer -Server vcenter -User username -Port password

Where vcenter is the name of your vCenter Server, username is your vCenter Server username, while password is your vCenter Server user's password.

Run this command to load the CBT-Reset.PS1 script:

.\CBT-Reset.PS1

Note: If you receive an error similar to File .\CBT-Reset.PS1 cannot be loaded because the execution of scripts is disabled on this system, check the previous step is applied correctly.

The script provides a report of virtual machines that are applicable. The script lists both virtual machines where CBT can be reset and those where CBT cannot be reset:

  • All virtual machines where CBT can be reset are listed.
  • All virtual machines where CBT cannot be reset (virtual machines that are powered off or have snapshots) are listed for notification purposes.

Note: When the script runs, a temporary virtual machine snapshot is taken. This avoids the needs for a power cycle of the virtual machine.

The script prompts you to confirm execution and proceed with the CBT reset of applicable virtual machines: if you choose to continue, CBT data is reset for the virtual machines that do not have snapshots and the power state is on.

Reset VMware Virtual Machine CBT (with screenshots)

Power off the VM, then right-click the VM, click [Edit settings], click the Options tab, select the General section, then click Configuration Parameters:

Resetting Changed Block Tracking files for VMware vSphere VMs

Set the "ctkEnabled" parameter value to false:

Resetting Changed Block Tracking files for VMware vSphere VMs

Set the all of the "scsi0:x.ctkEnabled" values to false:

Resetting Changed Block Tracking files for VMware vSphere VMs

Open the source folder via Datastore Browser and delete any -CTK.VMDK files:

Resetting Changed Block Tracking files for VMware vSphere VMs

Power the VM on and then rerun backup or replication job to re-enable CBT (this last step will work if you are using Veeam Backup & Replication software).

Download

The following archive can be viewed and downloaded only if logged/registered on Heelpbook (it's free to register, no fees).
[wpfilebase tag="file" id="238"]