User Tools

Site Tools


swap

All about swap

Who use mostly swap memory:

for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | head

Sort procesess by memory

ps aux --sort -rss | head

Count php-fpm used memory

ps aux | grep php-fpm | grep -v grep | awk '{sum+=$6} END {print sum}'

Release swap

sudo bash -c 'swapoff -a && swapon -a' &

SWAPFILE creation

First prepare file for swap:

fallocate -l 1024M /swapfile

or

dd if=/dev/zero of=/swapfile bs=1M count=1024

Change file permission:

chmod 600 /swapfile

Make swap on swapfile:

mkswap /swapfile

Turn on swap:

swapon /swapfile

Add to fstab - /etc/fstab

/swapfile none swap defaults 0 0
swap.txt · Last modified: 2019/10/28 19:37 by dreiggy

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki