TOOL ยป LINUX
Swap
Checking swap status โ
shell
swapon --show
free -hSwap file โ
The following commands creates and activates a swap file of 8000 MiB.
shell
dd if=/dev/zero of=/swapfile bs=1M count=8000 status=progress
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfileAlso add an entry to the swap file on /etc/fstab:
txt
/swapfile none swap defaults 0 0Swappiness โ
Read more here.
swap_tendency behaves diferently when bellow or above 100.
c
swap_tendency = mapped_ratio/2 + distress + vm_swappiness;- Lower than 50: Memory is already full and having distress (trouble to free memory).
- 50 means: Wait until we run out of memory until swapping.
- 55 means: When memory usage is 90%, start using swap.
- 60 means: When memory usage is 80%, start using swap.
Check the current swappiness with:
shell
sysctl vm.swappinessTemporarily set the swappiness:
shell
sysctl -w vm.swappiness=55To set it permanently, add to /etc/sysctl.d/99-swappiness.conf:
txt
vm.swappiness=55