Swap not being used

25,990

Solution 1

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

Solution 2

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.

Solution 3

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

sudo swapoff -a
sudo /sbin/mkswap /dev/sd##
sudo swapon -a
Share:
25,990

Related videos on Youtube

Andreas Hartmann
Author by

Andreas Hartmann

I am a nerd, or so they say. SOreadytohelp

Updated on September 18, 2022

Comments

  • Andreas Hartmann
    Andreas Hartmann over 1 year

    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.

  • matanster
    matanster over 6 years
    Is a value of 60 for swappiness an indication for not using swap before memory is completely full? is that a good default?
  • user929404
    user929404 over 5 years
    What did you find to be a good value for "swappiness"?
  • Andreas Hartmann
    Andreas Hartmann over 5 years
    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.
  • Yankee
    Yankee about 5 years
    Swappiness = 1 worked for me, while values as high as 80 and 100 didn't serve the purpose.
  • Ramesh Vishnoi
    Ramesh Vishnoi about 4 years
    how do i fix this?
  • Tod
    Tod over 3 years
  • Admin
    Admin almost 2 years
    how can I increase swappiness ?
  • Admin
    Admin almost 2 years
    @alper /etc/sysctl.conf - search for swappiness