Linuxhotel Wiki

Wie ging das nochmal?




Wie groß sollte Swap sein?

Brauche ich Swap?

  • - Sehr ausführlich warum Swap meist sinnvoll ist.
  • Swapping is necessary for two important reasons. First, when the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately. Second, a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache.
  • The casual reader may think that with a sufficient amount of memory, swap is unnecessary. But this brings us to the second reason. A significant number of the pages referenced by a process early in its life may only be used for initialisation and then never used again. It is better to swap out those pages and create more disk buffers than leave them resident and unused.

Zusätzlichen Swap-Speicher in einer Datei anlegen

Datei mit 500 MByte Größe anlegen:

fallocate -l 500M /swap

Datei als swap formatieren:

mkswap /swap

Swap Datei einbinden:

swapon /swap


free -m
swapon -s

Swap leeren

Prüfen, ob genug RAM verfügbar ist:

free -h

Swap leeren:

swapoff -a
swapon -a


Einschalten zur Laufzeit (z.B. mit einem Systemd Unit File):

echo 1 > /sys/module/zswap/parameters/enabled

Einschalten über Kernel-Parameter: (z.B. in /etc/default/grub.conf)



for i in /sys/kernel/debug/zswap/*; do echo -n "$i: "; cat $i; done
admin_grundlagen/swap.txt · Zuletzt geändert: 2022/03/14 10:45 von ingo_wichmann