A few weeks ago a new CBT bug KB2136854 was discovered in ESXi 6.0. We already wrote about it in this post: VMware ESXi 6.0 Introduced A Changed Block Tracking Bug (2136854) – Why Recovery Testing Is Critical and recommended using ReliableDR to certify your backups.

A VMware patch was released but after applying patch you need to reset CBT on all VMs.

Resetting CBT is an ardous task that requires you to poweroff the VM and edit VM ctkEnabled property using vSphere Client or use VMware APIs to disable/enable CBT and create/remove a temporary snapshot to purge CBT tables.

We have created a powershell cmdlet that uses VMware PowerCLI to automate this CBT reset operation in one or multiple VMs. As explained the script needs to create/remove a temporary snapshot so it is recommended that you do not run it during production hours on VMs that may be impacted by a VM snapshot.

Note: VMware updated KB to say that is not necessary to reset CBT on eager-zeroed-thick disks. But if you have a VM with multiple disks and any of them is not eager-zeroed-thick you will need to use Reset-CBT on that VM too.

Running the script and cmdlets

1. Download UnitrendsCBT.ps1 script from Unitrends GitHub repo.

2. Open PowerCLI (32-bit) console.
If you use default PowerCLI console you may get error “Operation is not valid due to the current state of the object” while running CBT-Reset.

3. CD to Path where you downloaded UnitrendsCBT.ps1 script.

PowerCLI C:\> cd C:\Unitrends\scripts\CBT

4. Allow Execution of unsigned powershell script. (Set-ExecutionPolicy Bypass)

PowerCLI C:\Unitrends\scripts\CBT> Set-ExecutionPolicy Bypass

5. Load Cmdlets from UnitrendsCBT.ps1 running command.

PowerCLI C:\Unitrends\scripts\CBT> . .\UnitrendsCBT.ps1

6. Connect to VMware server using PowerCLI Connect-VIServer.

PowerCLI C:\Unitrends\scripts\CBT> Connect-VIServer -Server vcenter01 -User root -Port password

5. Reset-CBT on one or multiple VMS.

PowerCLI C:\Unitrends\scripts\CBT> Get-VM test01|Reset-CBT

Sample usage and output

PowerCLI C:\Unitrends\scripts\CBT> Set-ExecutionPolicy Bypass

PowerCLI C:\Unitrends\scripts\CBT> Connect-VIServer -Server vcenter01 -User root -Port password

PowerCLI C:\Unitrends\scripts\CBT> . .\UnitrendsCBT.ps1

PowerCLI C:\Unitrends\scripts\CBT> Get-VM test0*|Get-CBT

Name   PowerState CbtEnabled
----   ---------- ----------
test01 PoweredOn       True
test02 PoweredOn       True

PowerCLI C:\Unitrends\unitrends-scripts> Get-VM test0*|Reset-CBT
[*] test01 : OK
[*] test02 : OK

That is all you need to reset CBT, Get-VM is a PowerCLI command that will get a list of VMs, that list will be passed to our Reset-CBT. So with just command you can reset CBT on a VM, all VMs in a cluster, folder, etc.

Other cmdlets
We have included other cmdlets that are not necessary to reset cbt but you may find useful to check and change CBT status Get-CBT, Get-ChangeId, Enable-CBT, Disable-CBT


PowerCLI C:\Unitrends\scripts\CBT> Get-VM  test0*|Disable-CBT
[*] test02 : OK

Verify CBT Status:
PowerCLI C:\Unitrends\scripts\CBT> Get-VM  test0*|Get-CBT

Name   PowerState CbtEnabled
----   ---------- ----------
test01 PoweredOn       False
test02 PoweredOn       False

PowerCLI C:\Unitrends\scripts\CBT> Get-VM  test0*|Enable-CBT
[*] test01 : OK
[*] test02 : OK

PowerCLI C:\Unitrends\scripts\CBT> Get-VM test0*|Get-CBT

Name   PowerState CbtEnabled
----   ---------- ----------
test01 PoweredOn       True
test02 PoweredOn       True


PowerCLI C:\Unitrends\scripts\CBT>  Get-VM test01|Get-ChangeId
[*] test01 -> 52 ba 35 cd 98 4e 0c 11-a4 7b f5 02 21 88 4c dd/4

PowerCLI C:\Unitrends\scripts\CBT> get-vm test01|Disable-CBT
[*] test01 : OK

PowerCLI C:\Unitrends\scripts\CBT> get-vm test01|Get-ChangeId
[*] test01 -> CBT is disabled

PowerCLI C:\Unitrends\scripts\CBT> get-vm test01|Enable-CBT
[*] test01 : OK

PowerCLI C:\Unitrends\scripts\CBT> get-vm test01|Get-ChangeId
[*] test01 -> 52 62 20 74 d6 82 b1 67-a5 55 69 60 da 9a 79 a2/4