How to reduce size of swap after a system is already installed?

One doesn't always want to reduce it, but often to increase its lazy usage instead — the more clean pages are already in swap, the better, it means they can easily be set off RAM when free RAM is needed. Linux VM, though, has some weird behavior regarding swapping — intensive disk I/O (like huge file cp) can make your system swap unwanted heavily. It can be mitigated to some degree by decreasing vm.swappinness and increasing vfs_cache_pressure although the effect of such countermeasures isn't always meeting expectations. I think it also makes sense to mention zswap here — for some workloads it can be useful.


To turn off swap temporarily, use (as root) the command:

swapoff -a

To turn it back on again:

swapon -a

To turn it off permanently, edit the file /etc/fstab and comment out any lines with swap in the type column.

More swap does not always improve performance. There are times when reducing it or turning it off is better - it all depends on the mix of applications.

I did a quick google and came up with this good article on the subject:

https://www.linux.com/news/software/applications/8208-all-about-linux-swap-space


Using it does, having it there does not. Slowing down will occur if you run too many memory hogging programs at once, which will cause the swap to be used.

If you really want to reduce it, boot a livecd and fire up gparted and resize the partition.

Tags:

Linux

Debian

Swap