Difference between revisions of "Swap"

From VoIPmonitor.org
Jump to navigation Jump to search
Line 22: Line 22:
 
check your swappiness values with
 
check your swappiness values with
 
  cat /pro/sys/vm/swappiness
 
  cat /pro/sys/vm/swappiness
 
+
(the value 60 means here use swap when less then 60% of RAM free)
 +
by
 
You can change it in a run-time (after restart default swap settings will beback) , effect is instant
 
You can change it in a run-time (after restart default swap settings will beback) , effect is instant
 
  echo '0' > /pro/sys/vm/swappiness
 
  echo '0' > /pro/sys/vm/swappiness
  
  
You can set the value permanent adding line at end of /etc/sysctl.conf
+
You can set the value permanent by adding the line at end of /etc/sysctl.conf
 
  vm.swappiness=0
 
  vm.swappiness=0
  
(The settings means to use swap only when there is no Ram free for latest kernels)
+
(0 value means to use swap only when there is no Ram free)
  
 
===Make swap empty===
 
===Make swap empty===
 
  swapoff -a
 
  swapoff -a
 
  swapon -a
 
  swapon -a

Revision as of 11:22, 7 May 2020

Swap

Swap usage can lead to performance degradation of your server. So we highly recommend to disable swap space and increase the memory.

How to disable

root@vmsniff:~# swapoff -a

Then edit the /etc/fstab file and comment out the swap lines. E.g.

proc            /proc           proc    defaults        0       0
# / was on /dev/md0 during installation
UUID=17e56a9a-0f42-44ca-90e8-570315708def /               xfs     relatime        0       1
# swap was on /dev/sda2 during installation
#UUID=0a403f5e-0505-4055-a219-70217b6b74d1 none            swap    sw              0       0
# swap was on /dev/sdb2 during installation
#UUID=4cf42564-4339-42ed-b7ec-29644a3085f1 none            swap    sw              0       0


How to configure

Most distributions have set by default to use swap when Ram usage exceeds 40% check your swappiness values with

cat /pro/sys/vm/swappiness

(the value 60 means here use swap when less then 60% of RAM free) by You can change it in a run-time (after restart default swap settings will beback) , effect is instant

echo '0' > /pro/sys/vm/swappiness


You can set the value permanent by adding the line at end of /etc/sysctl.conf

vm.swappiness=0

(0 value means to use swap only when there is no Ram free)

Make swap empty

swapoff -a
swapon -a