Manjaro Difference between revisions of "Swap/de"

Difference between revisions of "Swap/de"

From Manjaro
(Created page with "Um sicherzustellen, dass die Auslagerung beim Booten aktiviert ist, können wir einen Eintrag in {{ic|/etc/fstab}} hinzufügen. Am besten verwenden Sie dazu die UUID anstelle...")
(Updating to match new version of source page)
Line 19: Line 19:
=Brauche ich eine Auslagerung?=
=Brauche ich eine Auslagerung?=


<div class="mw-translate-fuzzy">
Das ist eine Frage, die nicht beantwortet werden kann, ohne einen Blick auf Ihre Konfiguration zu werfen. Selbst bei reichlich verfügbarem Speicher wird dieser oft als Auffangnetz oder sogar manchmal aufgrund spezifischer Anwendungsanforderungen verwendet, also werfen Sie einen Blick auf die folgende nicht abschließende Liste:
Das ist eine Frage, die nicht beantwortet werden kann, ohne einen Blick auf Ihre Konfiguration zu werfen. Selbst bei reichlich verfügbarem Speicher wird dieser oft als Auffangnetz oder sogar manchmal aufgrund spezifischer Anwendungsanforderungen verwendet, also werfen Sie einen Blick auf die folgende nicht abschließende Liste:
</div>
* Wenn Sie den Ruhezustand verwenden: ''ja, Sie müssen auslagern!''
* Wenn Sie den Ruhezustand verwenden: ''ja, Sie müssen auslagern!''
* Wenn Sie Dienste haben, die nicht immer aktiv sind, aber trotzdem ständig laufen: ''ja, Sie müssen auslagern!''
* Wenn Sie Dienste haben, die nicht immer aktiv sind, aber trotzdem ständig laufen: ''ja, Sie müssen auslagern!''
Line 29: Line 31:
Die benötigte Swap-Größe ist sehr variabel und hängt von ''Ihren'' spezifischen Anwendungen und der Arbeitslast ab.  Es gibt keine allgemeingültige Formel für die Größe des Auslagerungsspeichers, ohne die Nutzung über einen bestimmten Zeitraum hinweg zu überwachen.  Ein vernünftiger Ansatzpunkt wäre:
Die benötigte Swap-Größe ist sehr variabel und hängt von ''Ihren'' spezifischen Anwendungen und der Arbeitslast ab.  Es gibt keine allgemeingültige Formel für die Größe des Auslagerungsspeichers, ohne die Nutzung über einen bestimmten Zeitraum hinweg zu überwachen.  Ein vernünftiger Ansatzpunkt wäre:
* Bei weniger als 4 GB physischem Speicher (RAM) wird dringend empfohlen, dass der Swap-Speicher mindestens so groß sein sollte wie der RAM-Speicher. Außerdem wird empfohlen, dass der Swap-Speicher maximal doppelt so groß ist wie der RAM-Speicher, abhängig von der Größe des für das System verfügbaren Festplattenplatzes, wegen des abnehmenden Nutzens.
* Bei weniger als 4 GB physischem Speicher (RAM) wird dringend empfohlen, dass der Swap-Speicher mindestens so groß sein sollte wie der RAM-Speicher. Außerdem wird empfohlen, dass der Swap-Speicher maximal doppelt so groß ist wie der RAM-Speicher, abhängig von der Größe des für das System verfügbaren Festplattenplatzes, wegen des abnehmenden Nutzens.
* Bei moderneren Systemen (>4 GB) sollte Ihr Auslagerungsplatz mindestens der Größe Ihres physischen Speichers (RAM) entsprechen, '''wenn Sie den Ruhezustand verwenden''', andernfalls benötigen Sie mindestens ROUNDUP(SQRT(RAM)), d.h. die Quadratwurzel Ihrer Arbeitsspeichergröße aufgerundet auf das nächste GB. Das Maximum ist auch hier das Doppelte der Arbeitsspeichergröße, ebenfalls wegen des abnehmenden Nutzens.
* <span class="mw-translate-fuzzy">Bei moderneren Systemen (>4 GB) sollte Ihr Auslagerungsplatz mindestens der Größe Ihres physischen Speichers (RAM) entsprechen, '''wenn Sie den Ruhezustand verwenden''', andernfalls benötigen Sie mindestens ROUNDUP(SQRT(RAM)), d.h. die Quadratwurzel Ihrer Arbeitsspeichergröße aufgerundet auf das nächste GB. Das Maximum ist auch hier das Doppelte der Arbeitsspeichergröße, ebenfalls wegen des abnehmenden Nutzens.</span>
* Der einzige Nachteil, wenn Sie mehr Auslagerungsspeicher haben, als Sie tatsächlich benötigen, ist, dass der dafür reservierte Speicherplatz nicht für Anwendungs- oder Systemdaten verwendet werden kann.
* Der einzige Nachteil, wenn Sie mehr Auslagerungsspeicher haben, als Sie tatsächlich benötigen, ist, dass der dafür reservierte Speicherplatz nicht für Anwendungs- oder Systemdaten verwendet werden kann.


Line 60: Line 62:
         4TB            64GB              4160GB      8TB
         4TB            64GB              4160GB      8TB
         8TB            91GB              8283GB    16TB
         8TB            91GB              8283GB    16TB
{{note|Der größte Server, den einer der Autoren dieses Wikis jemals installiert hat, hatte in der Tat 8TB RAM}}
{{note|<span class="mw-translate-fuzzy">Der größte Server, den einer der Autoren dieses Wikis jemals installiert hat, hatte in der Tat 8TB RAM</span>}}
=Auslagerungsinformationen anzeigen=
=Auslagerungsinformationen anzeigen=


Line 69: Line 71:


Das folgende Skript wird:
Das folgende Skript wird:
* zeigt an, ob zswap aktiv ist oder nicht, und wenn aktiv, gibt zswap Parameter an, wenn es mit dem Befehl {{$ic|sudo}} ausgeführt wird
* <span class="mw-translate-fuzzy">zeigt an, ob zswap aktiv ist oder nicht, und wenn aktiv, gibt zswap Parameter an, wenn es mit dem Befehl {{$ic|sudo}} ausgeführt wird</span>
* eine Liste aller Anwendungen / Dienste anzeigen, die Auslagerung beanspruchen und wie viel sie beanspruchen, in absteigender Reihenfolge
* eine Liste aller Anwendungen / Dienste anzeigen, die Auslagerung beanspruchen und wie viel sie beanspruchen, in absteigender Reihenfolge


Line 119: Line 121:


First create and intialize the file to hold the swap.  For example, to create a 4GB swapfile, you could use the command:
First create and intialize the file to hold the swap.  For example, to create a 4GB swapfile, you could use the command:
  sudo fallocate -l 4G /swapfile
 
sudo mkswap /swapfile
  sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 status=progress




Set the appropriate permissions on the file.  It should be readable and writable only by {{ic|root}}.  This can be done with the command:
Set the appropriate permissions on the file.  It should be readable and writable only by {{ic|root}}.  This can be done with the command:
sudo chmod u=rw,go= /swapfile


sudo chmod 600 /swapfile
Next we need to format and enable the swapfile:
sudo mkswap /swapfile


Next we need to enable the swapfile with the {{ic|swapon}} command.  Following our example above this could be done with:
  sudo swapon /swapfile
  sudo swapon /swapfile




In order to ensure that the swap is enabled at boot we can add an entry to {{ic|/etc/fstab}}.  You can add the line to fstab manually or using the command:
In order to ensure that the swap is enabled at boot we can add an entry to {{ic|/etc/fstab}}.  You can add the line to fstab manually or using the command:
  sudo bash -c "echo /swapfile none swap defaults 0 0 >> /etc/fstab"
  sudo bash -c "echo /swapfile none swap defaults 0 0 >> /etc/fstab"


==Swapfiles on BTRFS==
==Swapfiles on BTRFS==
Line 213: Line 221:
zswap is compressed swap kept in RAM. zswap keeps the most frequently used pages in RAM and writes less frequently used pages to the swap space on disk.  In many workloads, this will result in increased swap performance and less wear and tear on SSDs.
zswap is compressed swap kept in RAM. zswap keeps the most frequently used pages in RAM and writes less frequently used pages to the swap space on disk.  In many workloads, this will result in increased swap performance and less wear and tear on SSDs.


To enable zswap with systemd-swap, simply alter the instructions above and set Linux Kernel parameter {{ic|zswap_enabled=1}}
To enable zswap with systemd-swap, simply alter the instructions above and set Linux Kernel parameter zswap_enabled=1
=Tuning & Performance Considerations=
=Tuning & Performance Considerations=


Line 224: Line 232:
{{ic|swappiness}} controls how likely a page is to be transferred to swap.  This value represents the percentage of the free memory before activating swap. The lower the value, the less swapping is used and the more memory pages are kept in physical memory where:
{{ic|swappiness}} controls how likely a page is to be transferred to swap.  This value represents the percentage of the free memory before activating swap. The lower the value, the less swapping is used and the more memory pages are kept in physical memory where:
* 0 disables swap
* 0 disables swap
* 60 is the default value which is ideal for a server running a lot of services
* 60 is the default value which is ideal for a server that is memory-starved and running a lot of services
* 100 is very aggressive swapping.
* 100 is very aggressive swapping.


For ''most'' computers the recommended value is 10: Theoretically, this means to only start swapping when RAM usage reaches around 90 percent.
For ''most'' desktop computers the recommended value is 10: Theoretically, this means to only start swapping when RAM usage reaches around 90 percent.


{{ic|vfs_cache_pressure}} is a percentage value that controls the tendency of the kernel to ''reclaim'' the memory which is used for caching of directory and inode objects.  The default value is 100.  Increasing this value will increase the rate in which these objects are removed from the RAM cache.  Decreasing it will allow these objects to be cached in memory longer, consuming additional RAM over time.  Depending on your specific workload, increasing or decreasing this value too far can have significant negative impacts on system performance.  Experimentation is needed to find the appropriate balance and the default value is reasonable.  In general, it is more common to optimize swappiness before experimenting with vfs_cache_pressure.
{{ic|vfs_cache_pressure}} used to be a percentage value that controls the tendency of the kernel to ''reclaim'' the memory which is used for caching of directory and inode objects with a default value of 100 on Kernels <5.4. On Kernels >=5.4 can be increased beyond 100.  Increasing this value will increase the rate in which these objects are removed from the RAM cache.  Decreasing it will allow these objects to be cached in memory longer, consuming additional RAM over time.  Depending on your specific workload, increasing or decreasing this value too far can have significant negative impacts on system performance.  Experimentation is needed to find the appropriate balance and the default value is reasonable.  In general, it is more common to optimize swappiness before experimenting with vfs_cache_pressure.


To set these values you can use the command {{ic|sysctl}}.  For example, to set the swappiness value to 10 you could use:
To set these values you can use the command {{ic|sysctl}}.  For example, to set the swappiness value to 10 you could use:
Line 248: Line 256:




[[Category:Contents Page]]
[[Category:Contents Page{{#translation:}}]]
Cookies help us deliver our services. By using our services, you agree to our use of cookies.