I've read it many a times online that swappiness should be decreased or disabled. Is it so, what does it do? I have 2GB of Ram, should I disable swappiness?

  • The question title and body do not match. The question title asks how to disable swap, the question body says only that the system "is lagging" and asks what to do. The two are not one and the same. – user Jun 9 '15 at 11:45
  • Fixed title and improved body @MichaelKjörling – Sharad Gautam Jun 9 '15 at 12:24
  • Here have a look at this Swap on Ubuntu. – vembutech Jun 9 '15 at 12:25
  • I find not so bad even the original question :) BTW to answer to the original question (now a little more hidden by the edit) I can suggest you to check if a specific process were using the swap. updatedb or things like virtuoso/akonadi can use a lot and in background, the HDD and the swap. Moreover is common to find that Linux requires and uses swap in a lighter way repect to Windows, of course it depends from the versions of each OS, the relative quantity of swap and from the program you use. – Hastur Jun 9 '15 at 13:15

According to Wikipedia:-

Swappiness is a Linux kernel parameter that controls the relative weight given to swapping out runtime memory, as opposed to dropping pages from the system page cache. Swappiness can be set to values between 0 and 100 inclusive. A low value causes the kernel to avoid swapping, a higher value causes the kernel to try to use swap space. The default value is 60, and for most desktop systems, setting it to 100 may affect the overall performance, whereas setting it lower (even 0) may decrease response latency.

According to Ubuntu Wiki:-

Swap space is the area on a hard disk which is part of the Virtual Memory of your machine, which is a combination of accessible physical memory (RAM) and the swap space. Swap space temporarily holds memory pages that are inactive. Swap space is used when your system decides that it needs physical memory for active processes and there is insufficient unused physical memory available. If the system happens to need more memory resources or space, inactive pages in physical memory are then moved to the swap space therefore freeing up that physical memory for other uses. Note that the access time for swap is slower therefore do not consider it to be a complete replacement for the physical memory. Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.

As I can see from my graph, Ubuntu is using much more swap than it should. You can easily turn off/decrease swapppiness as should be done on systems with more than 2GB of RAM which are not used for high-memory usage jobs such as editing High Defination Audi/Video/Images,

Your system is lagging because Swappiness is set to default value and it writes to Hard Disk which is 1000 times slower than writing to RAM.

To Check the current value of Swappiness,

cat /proc/sys/vm/swappiness


sysctl vm.swappiness

To disable or set Swappiness temporarily,in terminal, ( Ctrl+Alt+T),

sudo swapoff -a


sysctl -w vm.swappiness=10

To do this permanently, add below lines to your /etc/sysctl.conf file using sudo nano /etc/sysctl.conf:-


Here, x can be any number from 0 to 100 where:-

    0 = disable swap
    1 = minimum swap
   10 = recommended for >2GB
   60 = Linux Default for Swap
  100 = Maximum Swap, for >1GB Ram

You should not set the swappiness value to 0 unless you're much sure that you will never use up your RAM otherwise Out of Memory(OOM) Killer will kick in and start killing processes using up the RAM.

Here's some more info.

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.