Skip to content
Quieting a Homelab: CPU Governors, PCIe ASPM and a Windows VM on Emulated Hardware

Quieting a Homelab: CPU Governors, PCIe ASPM and a Windows VM on Emulated Hardware

My homelab lives on a small shelf: three Lenovo ThinkCentre Tiny boxes (i5-8400T, i5-9400T and i5-6500T) running Proxmox, plus a Synology DS923+ with four 16 TB drives. On top of Proxmox runs a Talos Linux Kubernetes cluster (one control plane, four workers) built with Terraform, with Cilium as CNI and everything else deployed through ArgoCD. Home Assistant, Pi-hole, Jellyfin, a backup server and a few other VMs and containers share the same hosts.

What started this was the noise: I kept hearing the fans on the shelf spinning up at random moments, even when nothing should have been happening. These Tiny boxes have small fans that are quiet at idle, so a fan ramping up means a CPU that is busier than it should be. I wanted to know why.

The whole shelf is on a single Shelly Plus Plug S, so Home Assistant gives me one honest number: what the rack draws at the wall. Before I started, the 24 hour median was 166 W.


Finding the noisy neighbour

Inside Kubernetes everything was quiet: about 0.6 cores per node. But on the host, the kvm processes were burning much more than their guests reported. The simplest reliable way to see per-VM CPU on a Proxmox host is to read the process CPU time from /proc twice:

p=$(cat /var/run/qemu-server/118.pid)
a=$(awk '{print $14+$15}' /proc/$p/stat); sleep 60
b=$(awk '{print $14+$15}' /proc/$p/stat)
echo "cores: $(echo "scale=2; ($b-$a)/6000" | bc)"   # 100 ticks/s * 60 s

The culprit was not part of the cluster at all: a Windows 10 VM I use for remote access, sitting at 1.13 cores while idle. Its config explained why:

net0: e1000=...,bridge=vmbr0
sata0: lvm-ssd:vm-118-disk-0,size=200G,ssd=1
cpu: x86-64-v2-AES,flags=+nested-virt;+aes;+pdpe1gb

An emulated Intel NIC, an emulated SATA disk, no guest agent, and nested virtualization on. Every packet and every disk access is a trip through QEMU’s device emulation.

Moving Windows to virtio without breaking boot

The fix is well known: virtio NIC, virtio-scsi disk. The trap is less known. I installed the virtio drivers in Windows, moved the boot disk from sata0 to scsi0, and Windows went straight into the automatic repair page (INACCESSIBLE_BOOT_DEVICE).

Installing the driver is not enough. Windows only marks vioscsi as a boot-start driver once it has actually seen a virtio SCSI controller with a disk on it. The procedure that works:

  1. Install virtio-win-guest-tools.exe from the virtio-win ISO (drivers plus the QEMU guest agent).
  2. Keep the boot disk on SATA and add a small temporary SCSI disk:
    qm set 118 --scsi1 lvm-ssd:1,iothread=1     # scsihw: virtio-scsi-single
  3. Boot Windows once from SATA. Check Device Manager for the Red Hat VirtIO SCSI pass-through controller, then shut down cleanly.
  4. Drop the temporary disk and move the boot volume:
    qm set 118 --delete scsi1
    qm set 118 --delete sata0
    qm set 118 --scsi0 lvm-ssd:vm-118-disk-0,ssd=1,discard=on,iothread=1
    qm set 118 --boot "order=scsi0;ide2;ide0;net0"
  5. Switch the NIC, keeping the same MAC so the DHCP lease survives:
    qm set 118 --net0 virtio=<same MAC>,bridge=vmbr0

Two details that cost me a few minutes: pending Proxmox changes only apply after a full stop and start (a reboot from inside the guest is not enough), and Windows sees the virtio NIC as a brand new adapter, so a static IP would have to be set again. I also removed nested-virt, since I don’t run WSL2 or Hyper-V in that VM.

Result: the VM went from 1.13 to 0.22 host cores at idle, and the host CPU from 65 °C to 57 °C. The fans went quiet.

Picking a CPU governor with numbers, not vibes

While looking at the hosts I noticed two of them were on the performance governor. Intel CPUs expose package power through RAPL, which makes it easy to measure instead of guess:

e=$(cat /sys/class/powercap/intel-rapl:0/energy_uj); sleep 30
f=$(cat /sys/class/powercap/intel-rapl:0/energy_uj)
echo "package W: $(echo "scale=1; ($f-$e)/30000000" | bc)"

On the i5-9400T host, with its normal workload (Home Assistant, two Kubernetes workers, Jellyfin and a few containers):

Governor / EPP Package power Effect
performance 13.0 W CPU idle 66%
powersave + balance_performance 8.4 W CPU idle 46%, no visible slowdown
powersave + balance_power 6.5 W load average jumped to 7.5 on 6 cores, too slow

With intel_pstate, powersave is not “slow mode”: it is the dynamic governor, and the energy performance preference (EPP) decides how eagerly it ramps up. balance_power saved two more watts but processes started queuing for CPU, which is not a trade I want for Home Assistant. The middle setting it is, applied at boot with a tiny unit:

# /etc/systemd/system/cpu-powersave.service
[Unit]
Description=CPU powersave governor with balance_performance EPP
After=multi-user.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c "for p in /sys/devices/system/cpu/cpufreq/policy*; do echo powersave > $p/scaling_governor; echo balance_performance > $p/energy_performance_preference; done"

[Install]
WantedBy=multi-user.target

PCIe ASPM on Realtek NICs, with a safety net

powertop showed the CPUs almost never reached a deep package C-state (pc2 around 1%, nothing deeper). One usual suspect is a PCIe device that keeps its link fully powered. All three hosts use a Realtek RTL8125 2.5GbE card, and on all three lspci -vv said ASPM Disabled.

Realtek NICs have a reputation for dropping their link with ASPM on, and on a cluster node a dead NIC means losing quorum and every VM on that host. So instead of just flipping it, I ran a small watchdog: enable L1, ping the gateway every two seconds for 15 minutes, and turn ASPM back off after three failed pings.

#!/bin/sh
D=/sys/bus/pci/devices/0000:02:00.0/link
echo 1 > $D/l1_aspm
fails=0; i=0
while [ $i -lt 450 ]; do
  if ping -c1 -W1 <gateway> >/dev/null 2>&1; then fails=0; else fails=$((fails+1)); fi
  if [ $fails -ge 3 ]; then echo 0 > $D/l1_aspm; logger "aspm-test: reverted"; exit 1; fi
  i=$((i+1)); sleep 2
done
logger "aspm-test: 15 min clean"

I ran it on one host first, then on the other two. No packet loss, no driver errors, and the Proxmox cluster stayed quorate throughout. After that it became another boot-time unit that writes 1 to /sys/bus/pci/drivers/r8169/*/link/l1_aspm.

Honest result: the saving is small, below 1 W per host. Deeper C-states (pc6, pc8) now appear, but with around twenty VMs and containers constantly waking the CPUs, the hosts are never idle long enough to sleep deeply. Still, it’s free.

Results

Before After
Windows VM, host CPU at idle 1.13 cores 0.22 cores
CPU package power, three hosts ~28 W ~21 W
Rack at the wall (Shelly) 166 W median ~156 W median
Hottest host 65 °C 57 °C

About 10 W at the wall, roughly 85 kWh a year, from settings that took an afternoon. Not dramatic, but the random fan spin-ups are gone and every change is measured and reversible.

Takeaways

  • When a host is loud, measure per-VM CPU on the host itself. The guest’s own view (or kubectl top) can look perfectly calm while QEMU is busy emulating hardware.
  • Windows VMs on emulated e1000 and SATA are expensive even at idle. Moving to virtio is worth it, as long as you let Windows see a virtio SCSI disk once before moving the boot disk.
  • RAPL makes governor choices measurable in 30 seconds. powersave with balance_performance was the sweet spot here.
  • Risky low-level tweaks are much less scary with an automatic revert. Fifteen lines of shell were enough.

A note on process: I did all of this in one session with Claude Code driving the shell over SSH, which made the “measure, change one thing, measure again” loop fast, and the auto-revert watchdog was the kind of safety net I would normally be too lazy to write myself.

Last updated on • Eduardo Fortes