Swap

From Halfface
Jump to navigation Jump to search

How to handle swappiness

Start top and press O then p to sort by swap.

top -c

Look at what is using swap. si and so is swap in and swap out.

vmstat 1

To return swap to ram.

swapoff -a; swapon -a

See swappiness value.

cat /proc/sys/vm/swappiness

To set swippiness value.

sudo sysctl vm.swappiness=0

sort processes on swap usage.

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