Skip to content

Instantly share code, notes, and snippets.

@denser
Forked from clexanis/40-vm-hotadd.rules
Created September 11, 2025 05:06
Show Gist options
  • Select an option

  • Save denser/c06ec36ca282337cb03c28d71a7165a9 to your computer and use it in GitHub Desktop.

Select an option

Save denser/c06ec36ca282337cb03c28d71a7165a9 to your computer and use it in GitHub Desktop.
Hyper-V Dynamic Memory rule for Debian
# On Hyper-V and Xen Virtual Machines we want to add memory and cpus as soon as they appear
ATTR{[dmi/id]sys_vendor}=="Microsoft Corporation", ATTR{[dmi/id]product_name}=="Virtual Machine", GOTO="vm_hotadd_apply"
ATTR{[dmi/id]sys_vendor}=="Xen", GOTO="vm_hotadd_apply"
GOTO="vm_hotadd_end"
LABEL="vm_hotadd_apply"
# Memory hotadd request
SUBSYSTEM=="memory", ACTION=="add", DEVPATH=="/devices/system/memory/memory[0-9]*", TEST=="state", ATTR{state}!="online", ATTR{state}="online"
# CPU hotadd request
SUBSYSTEM=="cpu", ACTION=="add", DEVPATH=="/devices/system/cpu/cpu[0-9]*", TEST=="online", ATTR{online}!="1", ATTR{online}="1"
LABEL="vm_hotadd_end"

Fix Hyper-V Dynamic Memory on Debian

On Debian system, Hyper-V Dynamic Memory don't workout-of-the-box. The hypervisor always says the VM need more memory and end up quickly giving the maximum memory. The added memory isn't available inside the guest, which make the whole functionality broken.

Adding the Ubuntu udev rules to /lib/udev/rules.d/ seems to solve both of these issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment