// Technical guide // Memory · KSM

KSM in Proxmox:
sharing RAM across VMs

KSM (Kernel Same-page Merging) is a Linux kernel feature that scans memory and merges identical pages belonging to different virtual machines into a single shared copy. The result: real RAM overcommit, more VMs per host and a lower cost per machine — which translates directly into density and savings after migrating off VMware.

// Table of Contents
  1. The kernel deduplicates memory
  2. Homogeneous environments gain the most
  3. Enabled automatically — under control
  4. What to be aware of
// 01 · How it works

The kernel deduplicates memory

KVM virtualisation marks VM memory as "mergeable" (madvise(MADV_MERGEABLE)). The kernel thread ksmd scans those regions in the background, checksums 4 KB pages and, when it finds identical pages owned by different VMs, keeps a single physical copy and points the other mappings at it in copy-on-write (COW) mode.

As long as no VM modifies such a page, they all share one copy in RAM. The moment one writes to it, the kernel instantly makes a private copy for that VM. From the guest's perspective nothing changes; the saving happens entirely on the host side.

ℹ️

KSM only merges anonymous memory marked as mergeable. It does not cover hugepages or file-backed shared memory — important for databases that use large pages.

// 02 · When it really saves

Homogeneous environments gain the most

KSM works better the more machines hold the same data in memory: the same OS, the same libraries, the same binaries. The classic case is dozens of VMs from one base image (e.g. 40× Debian or a farm of identical Windows Servers) — shared guest-kernel pages, glibc/.NET libraries and zeroed pages merge en masse.

In practice, on homogeneous clusters KSM recovers a realistic tens of percent of RAM — i.e. fitting more VMs on the same hardware without buying memory.

// 03 · KSM in Proxmox VE

Enabled automatically — under control

Proxmox runs the ksmtuned service, which enables KSM only under memory pressure — by default once host RAM usage crosses a threshold (around 80% of physical memory). So on a lightly loaded host KSM doesn't waste CPU scanning, and kicks in exactly when it helps.

What to checkWhere / command
Shared memory (UI)Node → Summary → KSM sharing
Pages sharedcat /sys/kernel/mm/ksm/pages_sharing
Page templatescat /sys/kernel/mm/ksm/pages_shared
Is KSM activecat /sys/kernel/mm/ksm/run (1 = running)

The saved RAM is approximately (pages_sharing − pages_shared) × 4 KB. On a healthy, homogeneous host this can be gigabytes.

💡

You can tune the threshold and scan aggressiveness in /etc/ksmtuned.conf (e.g. KSM_THRES_COEF). The defaults are sensible for most deployments.

// 04 · Cost, NUMA and security

What to be aware of

⚠️

KSM is a tool for density, not isolation. Where hard separation between neighbours matters, deliberately trade some savings for security.

We'll squeeze the most out of your RAM

We'll design a Proxmox cluster for real density — KSM, overcommit, NUMA and host selection tailored to your workloads, safely.

⚡ Free consultation → VM vs container: RAM usage