Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Reduce the chance of using swap if you have enough memory

Answer:

If you have enough memory but the Linux is still using swap at sometimes, you can adjust the swappiness parameter

1. See the current setting

# cat /proc/sys/vm/swappiness
60

The range is from 0 to 100 (lower value means you system will try to avoid swap as much as possible)

2. To set a lower value at runtime

# echo "30" >  /proc/sys/vm/swappiness

3. To set it permanently

# /sbin/sysctl -w vm.swappiness=30

Reboot after the changes.

  1. How to clear cache from memory in Linux?
  2. How to display swap information on Linux
  3. Create a swap partition using LVM
  4. Display physical memory size in Linux
  5. Swap last two words in Bash

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>