Vincent's Weblog

Enabling hot-swapping CPU/RAM on Proxmox guests

Proxmox has the ability to hot-plug CPU and RAM in guests. This can be usefull if you need to resize a VM's ram/cpu without shutting it down. Doing this requires a few steps though.

Enabling hot-plugging

First, shut down the VM and go to the options tab, here you can enable hot-plugging for CPU and RAM.

Next, go to the hardware tab, and enable numa for the CPU. This is required for hot-plugging to work. Also set the cores to the maximum amount of cores you want to be able to hot-plug. You'll use the vcpu option to set the amount of cores you want to use.

Next, we need to do some changes to the guest OS: we need to load 2 modules into the kernel and add some udev rules:

Run the following commands to enable the two modules

modprobe acpiphp
modprobe pci_hotplug

Next, we need to add the following to /lib/udev/rules.d/80-hotplug-cpu.rules

SUBSYSTEM=="cpu", ACTION=="add", TEST=="online", ATTR{online}=="0", ATTR{online}="1"

Next, add the following to /etc/default/grub (or add it to the GRUB_CMDLINE_LINUX_DEFAULT if it already exists)

GRUB_CMDLINE_LINUX_DEFAULT="movable_node memhp_default_state=online"

Next, reboot the server and you should be able to hot-plug CPU and RAM in the VM.