Swapping: Unterschied zwischen den Versionen
Admin (Diskussion | Beiträge) K |
Admin (Diskussion | Beiträge) |
||
(5 dazwischenliegende Versionen des gleichen Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
''Memory swapping is a computer technology that enables an operating system to provide more memory to a running application or process than is available in physical random access memory (RAM). When the physical system memory is exhausted, the operating system can opt to make use of memory swapping techniques to get additional memory. Mostly, swapping means the os outsource some memory to the swap space on a disk (In Linux this is a disk partition and in Windows there is a swap file called "pagefile.sys")'' | ''Memory swapping is a computer technology that enables an operating system to provide more memory to a running application or process than is available in physical random access memory (RAM). When the physical system memory is exhausted, the operating system can opt to make use of memory swapping techniques to get additional memory. Mostly, swapping means the os outsource some memory to the swap space on a disk (In Linux this is a disk partition and in Windows there is a swap file called "pagefile.sys")'' | ||
− | === Display processes using swap space | + | === Display processes using swap space === |
<source lang="bash"> | <source lang="bash"> | ||
find /proc -maxdepth 2 -path "/proc/[0-9]*/status" -readable -exec awk -v FS=":" '{process[$1]=$2;sub(/^[ \t]+/,"",process[$1]);} END {if(process["VmSwap"] && process["VmSwap"] != "0 kB") printf "%10s %-30s %20s\n",process["Pid"],process["Name"],process["VmSwap"]}' '{}' \; | awk '{print $(NF-1),$0}' | sort -h | cut -d " " -f2- | find /proc -maxdepth 2 -path "/proc/[0-9]*/status" -readable -exec awk -v FS=":" '{process[$1]=$2;sub(/^[ \t]+/,"",process[$1]);} END {if(process["VmSwap"] && process["VmSwap"] != "0 kB") printf "%10s %-30s %20s\n",process["Pid"],process["Name"],process["VmSwap"]}' '{}' \; | awk '{print $(NF-1),$0}' | sort -h | cut -d " " -f2- | ||
Zeile 7: | Zeile 7: | ||
− | == Swappiness configuration == | + | == Swappiness configuration (Debian based Linux distributions) == |
+ | ''This control is used to define how aggressive (sic) the kernel will swap memory pages. Higher values will increase aggressiveness, lower values decrease the amount of swap. A value of 0 instructs the kernel not to initiate swap until the amount of free and file-backed pages is less than the high water mark in a zone.'' | ||
'''Get current used swap space:''' | '''Get current used swap space:''' | ||
free -h | free -h | ||
Zeile 18: | Zeile 19: | ||
'''Change swappiness persitent (in sysctl.conf under /etc/)''' | '''Change swappiness persitent (in sysctl.conf under /etc/)''' | ||
− | # | + | <source lang="bash"> |
+ | # Add this line to change swappiness from a default (60) to 0 (decrease swap usage) | ||
vm.swappiness = 0 | vm.swappiness = 0 | ||
+ | </source> | ||
+ | |||
+ | |||
+ | |||
+ | == Disable Swap == | ||
+ | '''Disable swapping for the current session:''' | ||
+ | swapoff -a | ||
+ | |||
+ | '''Disable swap permanently:''' | ||
+ | *In '''/etc/fstab''' comment the entire line of the swap-space by adding a #. | ||
+ | |||
+ | |||
+ | |||
[[Kategorie:Linux]] | [[Kategorie:Linux]] |
Aktuelle Version vom 15. Juni 2021, 15:10 Uhr
Memory swapping is a computer technology that enables an operating system to provide more memory to a running application or process than is available in physical random access memory (RAM). When the physical system memory is exhausted, the operating system can opt to make use of memory swapping techniques to get additional memory. Mostly, swapping means the os outsource some memory to the swap space on a disk (In Linux this is a disk partition and in Windows there is a swap file called "pagefile.sys")
Display processes using swap space
find /proc -maxdepth 2 -path "/proc/[0-9]*/status" -readable -exec awk -v FS=":" '{process[$1]=$2;sub(/^[ \t]+/,"",process[$1]);} END {if(process["VmSwap"] && process["VmSwap"] != "0 kB") printf "%10s %-30s %20s\n",process["Pid"],process["Name"],process["VmSwap"]}' '{}' \; | awk '{print $(NF-1),$0}' | sort -h | cut -d " " -f2-
Swappiness configuration (Debian based Linux distributions)
This control is used to define how aggressive (sic) the kernel will swap memory pages. Higher values will increase aggressiveness, lower values decrease the amount of swap. A value of 0 instructs the kernel not to initiate swap until the amount of free and file-backed pages is less than the high water mark in a zone. Get current used swap space:
free -h
Get current swappiness configuration
sysctl vm.swappiness
Change swappiness for the current session (swappiness config are removed after reboot):
sudo sysctl vm.swappiness=0
Change swappiness persitent (in sysctl.conf under /etc/)
# Add this line to change swappiness from a default (60) to 0 (decrease swap usage) vm.swappiness = 0
Disable Swap
Disable swapping for the current session:
swapoff -a
Disable swap permanently:
- In /etc/fstab comment the entire line of the swap-space by adding a #.