Usage: stratum memory <action> [arguments]     (module type: service)

Memory management of the computer, with three techniques chosen by the
type of computer:
  compression    zram - compressed swap in RAM (Debian's
                 systemd-zram-generator), swap on disk only as an optional
                 low-priority reserve; zram has the highest swap priority
                 (32767) and is always used first
  deduplication  KSM with ksmtuned - equal memory pages of virtual machines
                 are kept once; only on a physical host
  ballooning     below a limit of free host memory the virtual machines
                 (libvirt) give memory back, never below their minimum, and
                 get it again when there is enough (stratum-memory-balloon)
zram-tools must not be active at the same time (start/enable refuse).

Actions:
  state                  "<state> <boot> <type>", e.g. "running enabled vm-reactor"
  status [--json]        state, boot setting, all settings, active swap; with
                         --json the same in one machine readable document
                         (zram statistics, swaps, sysctls, KSM, ksmtuned,
                         balloon service, recompression, recommendation)
  start                  memory management now only (until the next boot)
  stop                   off now (the boot setting is kept)
  enable                 at boot, and now
  disable                off now and at boot: VM defaults, disk swap as
                         before, ksmtuned and ballooning stopped
  restart                apply the settings again
  pending                exit 0 when a change waits for confirmation (never:
                         a risky action is refused and repeated with
                         STRATUM_FORCE=1)
  settings [--json]      all settings with their values
  setting <key> <value>  change one setting (applied at once when running):
      type <name>           type of computer - resets the other settings to
                            the defaults of this type (also: configure <name>)
      memory <GB>|auto      zram size in GB, or auto (the type's % of RAM)
      swappiness <0-200>|low|medium|high|maximum   (60 | 100 | 150 | 180)
                            how readily the kernel swaps
      compression zstd|lz4  zstd: better compression, about 3:1
                            (recommended); lz4: fastest, about 2:1, less CPU
      diskswap enable|disable     disk swap as low-priority reserve; without
                            any, /var/swapfile is created (at most 4 GB)
      dedup enable|disable  deduplication (KSM, ksmtuned)
      ballooning enable|disable   automatic ballooning of the machines
      threshold <5-50>      ballooning limit: % of free host memory below
                            which the machines give memory back
      recompress <minutes>  idle pages in zram are compressed again with the
                            second algorithm of the kernel every N minutes
                            (0 = off, up to 1440; needs recomp_algorithm)
  setting-choices <key>  the values of a setting and their labels
  recommend [--json] [type]
                         the values the type (default: the configured one)
                         would set on this computer, without changing
                         anything: type, memory_percent, memory_max_gb,
                         compression, swappiness, page_cluster,
                         min_free_kbytes, disk_swap, dedup, ballooning
  recommended [type]     apply those values and enable memory management
                         (what a frontend's one click does)
  options                the types of computer
  show [type]            the defaults of a type on this machine
  dedup-config           the values of ksmtuned (KEY, value, recommended)
  dedup-config recommended    the recommended values for a VM host
  dedup-config KEY=VALUE...   change values of /etc/ksmtuned.conf
                            (KSM_MONITOR_INTERVAL, KSM_SLEEP_MSEC,
                            KSM_NPAGES_BOOST, KSM_NPAGES_DECAY, KSM_NPAGES_MIN,
                            KSM_NPAGES_MAX, KSM_THRES_COEF, KSM_THRES_CONST)
  dedup-unmerge          split the merged pages again (exit 3: the memory use
                         can grow by the size of the merged pages; the core
                         repeats it with STRATUM_FORCE=1)
  recompress-now         compress the idle pages in zram again now (used by
                         stratum-memory-recompress.timer)
  refresh                switch deduplication, ballooning and recompression
                         on or off again by the settings (zram is not touched;
                         used after an update of the package)
  help                   show this help

The minimum memory of a machine for ballooning is part of its libvirt
definition (metadata https://www.skraba.net/stratum/memory, attribute
min in MiB) - e.g. written by VM Reactor; machines without it are left
as they are.

Types (defaults: memory, compression, disk swap, swappiness, dedup, ballooning):
  workstation  100 % RAM (max 16 GB), zstd, disk swap disable, swappiness 180, dedup off, ballooning off
  server       50 % RAM (max 8 GB), zstd, disk swap enable, swappiness 100, dedup off, ballooning off
  small        100 % RAM (max 8 GB), lz4, disk swap disable, swappiness 180, dedup off, ballooning off
  hypervisor   25 % RAM (max 4 GB), zstd, disk swap enable, swappiness 60, dedup on, ballooning on
  vm-reactor   auto (50/33/25/15 % of RAM, max 16/16/16/32 GB), zstd, disk swap enable, swappiness 100, dedup on, ballooning on
  vm-guest     50 % RAM (max 8 GB), zstd, disk swap disable, swappiness 100, dedup off, ballooning off

Own types: copy a type file to /etc/stratum/memory.d/<name>.profile and edit
it (keys: DESCRIPTION, ORDER, MEMORY_PERCENT (or auto: by the RAM),
MEMORY_MAX_GB, COMPRESSION, DISK_SWAP, SWAPPINESS, PAGE_CLUSTER, DEDUP,
BALLOONING, BALLOON_THRESHOLD, RECOMPRESS, MIN_FREE (auto: 1 % of RAM kept
free));
the same name as a Stratum type overrides it. The six Stratum types are also
compiled into the module, so it works when their files are missing.

Files:
  /etc/stratum/memory.conf             type and own settings
  /usr/lib/stratum/memory/profiles/    Stratum types (do not edit)
  /etc/stratum/memory.d/               own types
  /etc/systemd/zram-generator.conf.d/90-stratum-memory.conf   generator (boot)
  /run/systemd/zram-generator.conf.d/91-stratum-memory-run.conf  (start, now only)
  /etc/sysctl.d/90-stratum-memory.conf VM settings (enabled)
  /etc/ksmtuned.conf                   values of ksmtuned (dedup-config)
  /etc/tmpfiles.d/stratum-memory-ksm.conf   KSM merges empty pages
  /etc/systemd/system/stratum-memory-recompress.timer.d/   interval of the recompression
  /etc/fstab                           disk swap lines disabled as "#stratum-memory# ...";
                                       /var/swapfile marked "# swap file created by stratum-memory"
