2

I am trying to minimise disk writes as I am running on a usb flash. Is it better to set swappiness to zero or is it better to totally disable swap?

I have 8GB ram and I am using my server as:

  • samba server
  • afp server
  • sabnzbd/couchpotato/sick-beard

I might use it for apple timemeachine in the future but that is not in my immediate plans.

By the way - how do i turn off swap permenantly? Is it just a case of commenting out the line in the fstab?

Thanks.

Amir
  • 591

1 Answers1

4

Yes, if you want to disable swap entirely just comment out the line in fstab and reboot. Or, to avoid rebooting:

sudo swapoff -a

The downside if you entirely turn off swap is that you're left with no "safety net" if your processes start needing more memory than physically available. If you're confident that is not going to happen, it should be OK to disable swap.

Read here:

Is it safe to turn swap off permanently?

This has a very good explanation of whether it's safe to turn swap off and what swappiness means; swappiness 0 means it won't touch the swap file unless absolutely necessary (i.e. out of memory).

Now, if you want to minimize writes entirely there are other things you need to look into, such as logging for your applications (i.e. you probably don't want them writing logs to the USB flash). Be sure you look into that as well.

roadmr
  • 34,222
  • 9
  • 81
  • 93
  • Thanks. Yup I have written a bunch of stuff to tmpfs. So from what you have written it is safer to set swappiness to zero than to turn off swap. – Amir Feb 26 '12 at 00:07