Cold boot VM by guest OS reboot
When a VM is rebooted in OS, it keeps powered on at ESXi host during the whole boot process. Sometime it would be very useful when a OS reboot triggers a cold boot. In this post I show how to cold boot VM by guest reboot.
Cold boot is like to power cycle a computer. A VM needs to get through a power off state to see new hardware. Examples where a cold boot is necessary:
- VM version upgrade
- Get new CPU features after raising EVC mode of a Cluster
- Get new CPU features because of CPU microcode upgrade. Think of Spectre and Meltdown
To cold boot VM by guest reboot we need to set advanced setting
vmx.reboot.PowerCycle on VM level. This setting is available since 6.7 U3 respectively 6.5 U3 P04. When parameter is set, VM will cold boot at next guest reboot. When this happened, setting is removed automatically!
Set parameter using PowerCLI
Here I want to show how to set the parameter by using PowerCLI. This is quite simple and much more practically than using the GUI. Use this command to configure to cold boot VM by guest reboot:
Get-VM VM_name | New-AdvancedSetting -Name vmx.reboot.PowerCycle -Value $true -Confirm:$false
Of course you can create a more complex VM-selection before the first pipe (“|”).
To check if setting is configured, run:
Get-VM VM_name | Get-AdvancedSetting vmx.reboot.PowerCycle
To demonstrate the workflow I show how to raise the EVC mode of a VM after EVC mode was changed at cluster level. This will be done by just rebooting guest OS.
I set EVC mode of cluster to
intel-westmere and started the VM
SQL. You can see here current EVC of our VM is Westmere.
After that, I raised EVC to
intel-sandybridge. This allone does not change EVC mode of running VMs! Next I set parameter
vmx.reboot.PowerCycle for VM
Finally I rebooted guest by running:
Get-VM sql | Restart-VMGuest
After the reboot, EVC mode of VM raised too.
Just checking advanced setting after reboot … its gone
vmx.reboot.PowerCycleis also removed, when VM is shut down and powered on manually. To be more exact, it is removed at VM-start. So do not set parameter when VM is powered off!
- It is not that easy to monitor these cold boots. Because Power-On and Power-Off events are not generated. Also query of
boottimeproperty by running
(Get-VM VM_name).ExtensionData.runtime.boottimeshows last boot/reboot time, no matter if cold or warm reboot. What works is to monitor creation of
vmware.login VM folder. This file will be generate with cold boot.
- As I mentioned Spectre and Meltdown as example, you can use these great functions here to monitor VM mitigation state.
- Another example for EVC mode is when you enable it. Find more about this here.