Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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.

share|improve this answer
    
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 0:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.