Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hey all. I've been tweaking my Mint install lately, and am wondering if it is possible or advisable to get by without any swap for the kernel, no file, no partition, nothing. The swap doesn't seem very useful, right now I have 6GB ram, with 283MB free, but if you consider the 3180MB used by disk caching as "free" also, I have a lot of extra ram. The swap partition is only 1GB, and only has 131MB used, this is with a week of uptime and use of a lot of apps (I have about a dozen open ATM, including a virtualMachine with 1GB reserved for the VM). All the tutorials I have read seem to be old. I found one that said you should make a swap space at least double your ram, or even as large as 1GB (lol).
So, what is the worst case scenario?
Last edited by NeXuS_2006; 09-12-2013 at 01:32 PM.
The worst case scenario is that you run out of RAM and the oom_killer starts to kill your processes.
The worst case scenario when using a 1GB swap-space is that you have lost 1GB of space on your disk, something I would consider negligible in times with TB disks.
One use of swap on a system like yours is as a minor performance enhancement. A little stale anonymous data has been swapped out (as you reported) allowing slightly more ram to be used for cache, probably avoiding a few disk I/Os and making your system a trivial amount faster.
A second use of swap is as insurance against unexpected activity. If you use far more ram than expected, you would like that to merely slow down your system, rather than make the OOM killer destroy one or more processes.
The first effect is likely too small to measure and the second may be very unlikely (in your case). So the benefit of swap is likely small. But the cost is probably also small. How big is your hard drive and how full? If it is near full, you ought to get another or bigger hard drive and the proportional cost of a few GB of swap within that hard drive is trivial. If your hard drive is not near full then the space saved by not having swap has no value.
The old idea of "double ram" never made any sense back when it was commonly accepted. It makes less sense now. I think 2GB is a good size for swap on an ordinary home system. 2GB is a good swap size if you have 0.5GB of ram and 2GB is a good swap size if you have 32GB of ram. Your current 1GB of swap isn't bad either. 2GB is just my personal guess.
It is possible for you to get by with zero swap. Most likely, that would never cause a serious problem. Most likely the slow down from less caching would not be noticeable. But I still don't advise it, mainly because disk space is very inexpensive.
If you happened to have an old hard drive under 200GB and it is 80% to 90% full, you might factor in the inconvenience of installing a new hard drive with the performance problems of running too near a full filesystem, and decide to rationally overvalue a GB or two of space that might otherwise be swap. But if your drive is over 90% full, just get a real hard drive. If it is under 80% full, don't worry about a couple GB of swap space.
Maybe a modified version, "Swap is strictly optional." if you have enough ram. (actually snowpine said that)
Some apps stubbornly use swap still even if not needed. Even hard to flush it sometimes.
Knowing your needs is the only choice you have to decide if you need swap. A common desktop user may never need swap with 6 or more G ram. It would be easy for a power user or server to crash on that.
Maybe a modified version, "Swap is strictly optional." if you have enough ram.
Some apps stubbornly use swap still even if not needed. Even hard to flush it sometimes.
Knowing your needs is the only choice you have to decide if you need swap. A common desktop user may never need swap with 6 or more G ram. It would be easy for a power user or server to crash on that.
Thanks for the clarification. I understood that if you ran out of physical memory and have no swap, it is the same result as running out of physical memory and swap, which at 6Gb v 7Gb, is a 17% difference, not a whole lot.
I suppose I'll leave it as is, as pointed out swap space takes so few resources for the potential, albeit rare, headache. Thanks for the great discussion.
The worst case scenario is that you run out of RAM and the oom_killer starts to kill your processes.
The worst case scenario when using a 1GB swap-space is that you have lost 1GB of space on your disk, something I would consider negligible in times with TB disks.
If you run out of RAM without swap, indeed the OOM killer starts killing processes hogging the RAM. It may also kill more innocent processes.
If you run out of RAM with swap, your computer will slow to a crawl and it will take you 10 - 20 min to kill the offending app.
I prefer the former, and I only have 2GB of RAM and I have only run out two or three times due to a leaky program.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.