]> git.proxmox.com Git - pve-docs.git/blame - kernel-samepage-merging.adoc
vzdump: drop overly scary & outdated warning about fleecing
[pve-docs.git] / kernel-samepage-merging.adoc
CommitLineData
12804f68
DW
1[[kernel_samepage_merging]]
2Kernel Samepage Merging (KSM)
3-----------------------------
4ifdef::wiki[]
5:pve-toplevel:
6endif::wiki[]
7
8Kernel Samepage Merging (KSM) is an optional memory deduplication feature
9offered by the Linux kernel, which is enabled by default in {pve}. KSM
10works by scanning a range of physical memory pages for identical content, and
11identifying the virtual pages that are mapped to them. If identical pages are
12found, the corresponding virtual pages are re-mapped so that they all point to
13the same physical page, and the old pages are freed. The virtual pages are
14marked as "copy-on-write", so that any writes to them will be written to a new
15area of memory, leaving the shared physical page intact.
16
17Implications of KSM
18~~~~~~~~~~~~~~~~~~~
19
20KSM can optimize memory usage in virtualization environments, as multiple VMs
21running similar operating systems or workloads could potentially share a lot of
22common memory pages.
23
24However, while KSM can reduce memory usage, it also comes with some security
25risks, as it can expose VMs to side-channel attacks. Research has shown that it
26is possible to infer information about a running VM via a second VM on the same
27host, by exploiting certain characteristics of KSM.
28
29Thus, if you are using {pve} to provide hosting services, you should consider
30disabling KSM, in order to provide your users with additional security.
31Furthermore, you should check your country's regulations, as disabling KSM may
32be a legal requirement.
33
34Disabling KSM
35~~~~~~~~~~~~~
36
37To see if KSM is active, you can check the output of:
38
39----
40# systemctl status ksmtuned
41----
42
43If it is, it can be disabled immediately with:
44
45----
46# systemctl disable --now ksmtuned
47----
48
49Finally, to unmerge all the currently merged pages, run:
50
51----
52# echo 2 > /sys/kernel/mm/ksm/run
53----
54