5

my swap is not being used, no matter how full my RAM gets. This is my swapon output:

NAME      TYPE       SIZE USED PRIO
/dev/dm-2 partition 31,9G 3,5M   -1

Could the PRIO -1 be a problem?

cat /proc/sys/vm/swappiness
60

My swappiness is 60.

cat /proc/swaps
Filename             Type       Size        Used    Priority
/dev/dm-2            partition  33456124    3524    -1

I have 32GB of RAM and 32GB of swap, but currently when my memory runs my system will just lock up permanently rather than start swapping. Anything I can do about that?

Basically I am trying to run an application that will eat about 30GB of memory, while me physical memory is already half full. While it is booting up and loading data into memory my system just freezes, once the physical memory is full. And no it doesn't appear to just lock up while it is swapping, since even after a while doesn't unfreeze.

5

Increasing swappiness fixed it. The swap was enabled, but for some reason only used when the memory was completely full, and no sooner.

  • 1
    Is a value of 60 for swappiness an indication for not using swap before memory is completely full? is that a good default? – matt Jan 24 '18 at 14:05
  • What did you find to be a good value for "swappiness"? – user929404 Sep 27 '18 at 12:36
  • 1
    60 is the default. If that doesn't swap enough, increase the value in 5-10 increments and retest. If you have lots of memory and want to use it all before swapping try a very low value. 0 means the system will never swap, 1 means that it will only swap in order to avoid a crash. But based on my original question, sometimes it may make sense to use a higher value if your memory fills up very rapidly and you experience lockups. – Andreas Hartmann Sep 27 '18 at 14:00
  • Swappiness = 1 worked for me, while values as high as 80 and 100 didn't serve the purpose. – Yankee Mar 22 at 9:09
3

Don't think so. First check cat /etc/fstab for your swap partition, then try formatting the swap file system with

  1. sudo swapoff -a
  2. sudo /sbin/mkswap /dev/sd##
  3. sudo swapon -a
0

In my case I installed another Ubuntu test instance and formatted the swap for it, so the UUID of the swap device was old in fstab, I just changed it to current and it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.