I have a system with 4 gigs of RAM and an SSD. I heard allocating swap on SSD is a bad idea because SSD has got limited write cycle.
So when I see < 100 MiB of pages is written to the swap, and I have some available space on the RAM, I just use an alias 'rswap' to turn it off and on again:
alias rswap='sudo swapoff /dev/sda3 && sudo swapon /dev/sda3'
Now this moves the pages back to RAM, and the swap gets down to 0 bytes. The RAM usage increases, but I never had a problem with applications so far.
Also, there are several reasons why the swap is used despite having available RAM. One of them is this one!
Is it a good idea to run the aliased command rswap
repeatedly?
swappiness
. – Randall Jun 14 '19 at 21:23Here's the problem: https://unix.stackexchange.com/questions/510997/why-does-linux-write-to-swap-space-even-if-the-system-has-available-storage-whil
– 15 Volts Jun 15 '19 at 04:46