Skip to content

Proxmox KSM (Kernel Samepage Merging) Power & Performance Optimization ​

This operational runbook documents the rationale, architectural impact, and step-by-step procedure for disabling Kernel Samepage Merging (ksm / ksmtuned) across the homelab cluster nodes (pve, pve2, pve3) and the Proxmox Backup Server (PBS).


🏛️ Executive Summary & Context ​

By default, Proxmox VE enables ksmtuned (Kernel Samepage Merging tuning daemon). KSM periodically scans anonymous memory pages allocated by KVM/QEMU virtual machines, searches for identical memory blocks, and merges them into shared Copy-on-Write (CoW) pages to save host physical RAM.

However, in this homelab architecture:

  1. Workloads are ~90% LXC Containers: LXC containers run directly on the host Linux kernel and do not flag memory with MADV_MERGEABLE. KSM does not merge memory across standard LXC containers.
  2. Single Active VM (homeassistant on PVE-1): With only one active QEMU VM running cluster-wide, KSM has zero other virtual machines to deduplicate memory against.
  3. Abundant RAM Headroom: All nodes maintain >30–75% free RAM under normal operations.
  4. Active CPU Wakeup Penalty: ksmtuned background scanning prevents CPU cores on both Intel (i7-10700) and AMD (Ryzen Embedded R2314) processors from staying in deep sleep package C-states (C6/C8/C10), creating unnecessary background idle power draw, fan noise, and heat.

📊 Node Hardware & Power Baseline Inventory ​

All nodes are connected to energy-monitoring smart plugs integrated into Home Assistant:

NodeHostname / IPCPU & RAMWorkload TypeHA Power SensorPre-Change BaselinePost-Change Status
PVE-1pve
192.168.0.100
Intel i7-10700 (8C/16T)
32 GB RAM
1 VM (homeassistant) + 6 LXCssensor.power_plug_2_pve_power~40 W – 46 Wksmtuned disabled
PVE-2pve2
192.168.0.101
AMD Ryzen Embedded R2314 (4C/4T)
16 GB RAM
HA Standby / Failoversensor.power_plug_4_pve2_power~6 W – 8 Wksmtuned disabled
PVE-3pve3
192.168.0.102
AMD Ryzen Embedded R2314 (4C/4T)
16 GB RAM
HA Standby / Failoversensor.power_plug_6_pve3_power~3 W – 5 Wksmtuned disabled
PBSPBS
192.168.0.103
Proxmox Backup ServerNative PBS Daemons (0 VMs)sensor.power_plug_1_pbs_power~3 W – 5 Wksmtuned disabled

NOTE

Proxmox Backup Server (PBS) is a standalone backup target running native daemons rather than a hypervisor. It runs no QEMU VMs; disabling ksmtuned on PBS eliminates dormant background daemon cycles.


🛠️ Step-by-Step Procedure ​

1. Disable ksmtuned and ksm on Proxmox Nodes ​

Execute the following commands on each node (pve, pve2, pve3, and PBS):

bash
# 1. Stop and disable ksmtuned and ksm services
systemctl stop ksmtuned ksm
systemctl disable ksmtuned ksm

# 2. Deactivate KSM in the active running kernel immediately
echo 0 > /sys/kernel/mm/ksm/run

(Alternatively via Proxmox Web GUI: Navigate to Node $\rightarrow$ System $\rightarrow$ Services $\rightarrow$ select ksmtuned $\rightarrow$ Stop, then Disable).


2. Verification ​

Verify that the services are dead and kernel memory sharing is disabled:

bash
# Check service status (should return inactive / disabled)
systemctl is-active ksmtuned ksm
systemctl is-enabled ksmtuned ksm

# Verify kernel KSM run state (should return 0)
cat /sys/kernel/mm/ksm/run

# Verify pages sharing (should return 0)
cat /sys/kernel/mm/ksm/pages_sharing

Via Proxmox API / MCP:

json
{
  "ksm": {
    "shared": 0
  }
}

3. How to Revert (If Multiple Heavy VMs Are Deployed) ​

If the cluster workload changes in the future to include multiple identical Windows or Linux VMs requiring memory overcommitment:

bash
# Enable and start KSM daemons
systemctl enable ksmtuned ksm
systemctl start ksmtuned ksm

# Enable kernel KSM run state
echo 1 > /sys/kernel/mm/ksm/run

📈 Power Monitoring in Home Assistant ​

The power impact of this optimization can be tracked live or graphed over time in Home Assistant:

  • PVE-1: sensor.power_plug_2_pve_power
  • PVE-2: sensor.power_plug_4_pve2_power
  • PVE-3: sensor.power_plug_6_pve3_power
  • PBS: sensor.power_plug_1_pbs_power

Authoritative operational repository and DR hub.