Forum Discussion
Maximize Your Cloud Efficiency: Embrace VM Hibernation
In the ever-evolving landscape of cloud computing, cost management remains a top priority for businesses. One innovative feature that stands out for its ability to drive down costs without compromising performance is VM Hibernation. This powerful tool allows you to pause your Virtual Machines (VMs) when they’re not in active use, leading to significant savings on compute costs.
Ideal Use Cases for VM Hibernation.
VM Hibernation shines in several scenarios:
- Virtual Desktops and Dev/Test Servers: These environments often don’t require round-the-clock operation, making hibernation an excellent choice for reducing expenses.
- Memory-Intensive Applications: Systems that take considerable time to boot up due to such applications can benefit immensely. By initializing these applications on VMs and then hibernating them, you can have “prewarmed” VMs ready to spring into action swiftly, with all applications already in the desired state.
Understanding the Hibernation Process
When you opt to hibernate a VM, Azure orchestrates a seamless suspend-to-disk action. It securely stores the VM’s memory contents on the OS disk and then deallocates the VM. Upon reactivation, these contents are promptly restored to memory, allowing your applications and processes to pick up exactly where they left off.
Cost Implications of Hibernating Your VM
A hibernated VM incurs no charges for VM usage. Instead, you’re only billed for the storage (OS and data disks) and networking resources (like IPs) that remain attached to the VM.
Key Points When Hibernating a VM:
- Trigger hibernation through various means like the Azure portal, CLI, PowerShell, SDKs, or APIs.
- The memory contents are preserved on the OS disk while the VM is deallocated and powered off.
- Temporary disk data is not retained.
- The OS disk, data disks, and NICs stay attached, and any static IPs remain unchanged.
- Enjoy freedom from VM usage billing during hibernation.
- Storage and networking resource billing continues as usual.
Embracing VM Hibernation is a smart move for any cloud-centric organization looking to optimize operations and reduce costs. It’s not just about saving money; it’s about smart resource management that aligns with your business needs.
Hibernation support is limited to certain VM sizes and OS versions. Make sure you have a supported configuration before using hibernation.
The following Windows operating systems support hibernation:
- Windows Server 2022
- Windows Server 2019
- Windows 11 Pro
- Windows 11 Enterprise
- Windows 11 Enterprise multi-session
- Windows 10 Pro
- Windows 10 Enterprise
- Windows 10 Enterprise multi-session
The following Linux operating systems support hibernation:
- Ubuntu 22.04 LTS
- Ubuntu 20.04 LTS
- Ubuntu 18.04 LTS
- Debian 11
- Debian 10 (with backports kernel)
- RHEL 9.0 and higher (with minimum kernel version 5.14.0-70)
- RHEL 8.3 and higher (with minimum kernel version 4.18.0.240)
VM sizes with up to 64-GB RAM from the following General Purpose VM series support hibernation.
- Dasv5-series
- Dadsv5-series
- Dsv5-series
- Ddsv5-series
- Easv5-series
- Eadsv5-series
- Esv5-series
- Edsv5-series
VM sizes with up to 112-GB RAM from the following GPU VM series support hibernation.
- NVv4-series (in preview)
- NVadsA10v5-series (in preview)
To enable hibernation on an existing VM, you can use Azure CLI, PowerShell, or REST API.
Enabling hibernation on an existing Windows/ Linux VM using PowerShell
1. To use Azure PowerShell to enable hibernation on an already-running virtual machine, stop the machine first using Stop-Az vm deallocate. Update the VM and OS disk after the VM has been deallocated.
Stop-AzVM -ResourceGroupName 'TestResourceGroup' -Name 'TestVMName'
2. Update the OS disk to change SupportsHibernation to true after the virtual machine has been halted. You can skip this step and go on to the next if SupportsHibernation is already set to true.
$disk = Get-AzDisk -ResourceGroupName "TestResourceGroup" -DiskName "myOSDisk"
$disk.SupportsHibernation = $True
Update-AzDisk -ResourceGroupName ‘myResourceGroup' -DiskName 'myOSDisk' -Disk $disk
3. Enable hibernation on the VM.
$vm= Get-AzVM -ResourceGroupName "TestResourceGroup" -Name "TestVM"
Update-AzVM -ResourceGroupName "TestResourceGroup" -VM $vm -HibernationEnabled
4. After launching the virtual machine, configure the guest operating system for hibernation.
Start-AzVM -ResourceGroupName 'TestResourceGroup' -Name 'TestVM'
General limitations
- When hibernation is activated on a virtual machine, you can resize it; when hibernation is disabled, you cannot. It should be either Running or Stopped for the virtual machine.
- Nested Virtualization only supports hibernation if Trusted Launch is turned on in the virtual machine.
- You are unable to attach, detach, or alter any disks or NICs connected to a hibernated virtual machine. Rather, a Stop-Deallocated state must be applied to the VM.
- There is no capacity guarantee when a virtual machine (VM) is hibernated, hence there may not be enough capacity to restart the VM at a later time. You can attempt starting the virtual machine (VM) later if, in the extremely unlikely event that capacity problems arise. Hibernated VM capacity is not guaranteed by capacity reservations.
- Using the Azure portal, CLI, PowerShell, SDKs, and API is the sole way to hibernate a virtual machine. The virtual machine (VM) is still billed even when it is put into hibernation by guest OS activities.
If you want step-by-step guidance to enable hibernation for existing Windows VM, you can check the below YouTube video.
https://www.youtube.com/watch?v=cLs6DI8cz_w