My Ubuntu 12.04 x64 on Dell XPS 15 with 8GB of RAM has been really sluggish.

After some searching I came across post about swappiness. I noticed that swappiness on my system was reported as 0 which means swapping should only start when memory is all used and yet is was actually acting much the same as when swappiness is 60.

I set swappiness to 10 using:

echo 10 > /proc/sys/vm/swappiness

and update /etc/sysctl.conf with:

vm.swappiness = 10

After rebooting I notice that swappiness is reported as 0 again with same sluggish performance. I ran echo 10 > /proc/sys/vm/swappiness and the performance improved remarkably.

I rebooted again and check swappiness, it was reported as 0 again. I executed sudo sysctl -p and could see the values from sysctl.conf take effect.

It seems that the value from /etc/sysctl.conf is ignored on boot.

I have a notebook with Ubuntu 12.04 32 bit and I also applied the same configuration. On the notebook the changes do take effect as expected and remain after a reboot.

Has anyone come across this kind of problem? How can I fix it?

  • 1
    Is there a swap partition? Do you have reasons, other then the sluggishness, to believe that it's been running out of RAM? – mikewhatever Jul 24 '12 at 22:12
  • There is a swap partition and the system just start using it long before running out of memory. The swappiness parameter configures how soon the kernel should do it. With a value of 100 it start swapping aggressively immediately. With a value of 0 it should only start swapping once all RAM is used. – Corneil du Plessis Jul 25 '12 at 6:15
  • The real problem is that a change to the configuration is ignored when the system boots. The second problem is that a value of 0 for swappiness seems to have the opposite effect. – Corneil du Plessis Jul 25 '12 at 6:16
  • @CorneilduPlessis The reason for this is because kworker will get stuck in a loop searching for swap that does not exist. Change swappiness to 30 and see if you don't have better performance. – mchid Jun 20 '14 at 5:35

Try this:

Start a terminal emulator and run

cd /etc/sysctl.d/
echo "vm.swappiness = 10" | sudo tee 60-memory-management.conf
sudo chmod 644 60-memory-management.conf

Reboot and check if the new values are in use with:

cat /proc/sys/vm/swappiness`
| improve this answer | |
  • I tried this and still end up with swappiness = 0 after reboot. sudo sysctl -p is only way that set swappiness to the correct value. – Corneil du Plessis Aug 27 '12 at 20:28
  • @CorneilduPlessis I had the same issue. vm.swappiness was set in /etc/sysctl.conf; changing the value there solved the problem. – xofer Jul 31 '14 at 19:47

I just bung the following in my /etc/rc.local

sysctl -w vm.swappiness=1 #Discourage swapping.

Basically, you can run this command: sudo sysctl -w vm.swappiness=1 at any time to change the swappiness.. cat /proc/sys/vm/swappiness gives 1 after this.

| improve this answer | |

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.