I recently had to enable CBT in my VMware vSphere environment, on a good amount of Virtual Machines.
What is Change Block Tracking (CBT) ? If you are not familiar with CBT, checkout the following articles:
- Eric Siebert: What is Change Block Tracking (CBT) ?
- VMware KB: Changed Block Tracking (CBT) on virtual machines
- VMware Documentation: Low Level Backup Procedures
How to implement CBT, what do you need ?
- VM version 7 at least,
- No snapshot on your VM
- Enable CBT,
- Finally the VM must go through a stun-unstun cycle (power on, resume after suspend, migrate, or snapshot create/delete/revert) before the reconfiguration takes effect.
How to Enable CBT on your VM ? (GUI)
Note: When the VM is Powered ON you won't be able to access those settings.
However, It is possible to do it via PowerShell even when the VM is started. :-) (see below)
Navigate to Configuration Parameters and add the following Entries.
Right click on your VM, select Edit Settings/Options Tab/Advanced/General. Click on Configuration Parameters and add the following entries |
This enable CBT on your VM. ctkEnabled = true |
Additionally, you need to add an entry for each disk. (in this example I had two virtual disks) scsi0:0.ctkEnabled = true scsi0:1.ctkEnabled = true |
You can do the following even if your VM is Powered ON.
# Check and Add the PowerCli Snaping if not already present if(-not(Get-PSSnapin -Registered -Name "VMware.VimAutomation.Core"){ Add-PSSnapin -Name VMware.VimAutomation.Core} # Connect to my Vcenter Connect-VIServer -Server vcenter.fx.lab #Here is aRunning the script on TESTSERVER04 to enable CBT $vmtest = Get-vm TESTSERVER04 | get-view $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec $vmConfigSpec.changeTrackingEnabled = $true $vmtest.reconfigVM($vmConfigSpec)
How to Apply this CBT configuration ?
Once you enable CBT, the VM must go through a stun-unstun cycle (power on, resume after suspend, migrate, or snapshot create/delete/revert) before the reconfiguration takes effect.
In my case i will create/delete a snapshot since I don't want any downtime to occur.
State of my the VM files, before the Snapshot, |
State of my VM files, after the creation of the Snapshot. |
State of my VM Files, after the deletion of the Snapshot. |
CBT is now enabled on this VM.
How to Check if CBT is enabled on your VM (PowerShell/PowerCli)
# Check if your VM has (Change Block Tracking) enabled or not (Get-VM -Name TESTSERVER04).ExtensionData.Config.ChangeTrackingEnabled # Find VMs where CBT (Change Block Tracking) is Enabled Get-VM| Where-Object{$_.ExtensionData.Config.ChangeTrackingEnabled -eq $true}
Thanks ! Very helpful
ReplyDeleteThank you! Glad to help someone :-)
DeleteI am looking at having to do a large roll-out of enabling CBT and came across your post. One question... you mention having to enable CBT on each VMDK attached to the VM. However, in your PowerShell script it looks like you are only using one command to turn CBT on. ("$vmConfigSpec.changeTrackingEnabled = $true") Does this automatically enable CBT for ALL VMDK's attached to the VM? Thanks in advance for your response!
ReplyDeleteHi!
DeleteThanks for the comment, The post show first how to do it via the GUI then how to do it via PowerCli.
Yes once you do $vmConfigSpec.changeTrackingEnabled = $true it will automatically enable it on all the vmdk.
Once you enabled CBT, your VM will need to go through a stun-unstun cycle (power on, resume after suspend, migrate, or snapshot create/delete/revert) before the reconfiguration takes effect.
Hope this help
This saved my day! thanks!
ReplyDeleteThank you for your comment, happy to help ;-)
Delete