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.
For a machine that requires a very large amount of physical memory (e.g. 4 or 8 GB and up) and that is diskless, is it going to be a big problem?
I ask because if it's diskless, obviously you cannot have any swap space. What are the implications of no swap space on something with so much memory - in fact, on any machine, for that matter?
In general terms, would it be better to forgo the benefits of a diskless server (e.g. maintenance, expense) and just purchase a disk to act as a swap drive, or is it ok to avoid the disk?
After all, isn't swapping a 'bad' thing? So if your server is about to swap, then you know its time to either add more memory or more machines? Or would adding more physical memory every time a machine would have swapped to disk be a recipe for bankruptcy?
Swap is essentially emergency memory; a space set aside for times when your system temporarily needs more physical memory than you have available in RAM. It's considered "bad" in the sense that it's slow and inefficient, and if your system constantly needs to use swap then it obviously doesn't have enough memory. But if it only happens occasionally then there's no problem. That's its purpose, after all.
If you have enough RAM to handle all of your needs, and don't expect to ever max it out, then you should be perfectly safe running without a swap space. But if you ever do max out then you'll simply suffer from whatever symptoms the system normally suffers when memory is low, and that depends on how everything is programmed. Now I don't know for sure how Linux (the kernel) handles low memory situations but I can guess that at the very least it will try to fail gracefully, and that goes for most well-written programs as well. I imagine you still might run the risk of system freezes though, where there simply isn't enough memory available for even the most basic of functions.
Do note that exactly the same thing will happen if you DO have a swap space and go beyond your total RAM+swap allocation.
So long story short, swap is designed for occasional "overflow" use. If you have constant low-memory problems, you should get more RAM.
I'm pretty sure you can get by without swap space, especially if you're running that much physical memory. That said, swap and physical RAM work somewhat differently as far as how they handle memory usage. It might be something to look into depending on the particular needs of your system. You could always throw an old drive in there allocated solely to swap, if nothing else.
Hope that helps
Last edited by nakedlunch; 07-25-2007 at 08:50 AM.
It is absolutely and clearly false that you should aim your configuration at no swap. A little swap is a good thing - any system will have some pages that are so cold and idle that they don't "deserve" to be in RAM. Having those on disk (swapped out) is only of benefit to you.
In general, swap OUT is good for you. What you want to avoid is swap IN. Swapping in means that something is actually waiting on pages that the kernel thought were cold/useless. Or that you've pushed your system so far past your amount of RAM that you're thrashing (which just means "inefficient because of so much waiting on swapins").
These days, systems often have SSD, which is far more effective in supporting swap than HDs ever were. A modest amount of swapins, from SSD, definitely won't hurt you, since they're about 100x lower latency than from HD. This is a bit of a crutch, to be sure, but can extend the lifespan of a low-memory laptop, for instance. Remember to TRIM your SSD periodically, though.
You can also provide for swapping to a "swap file" if you have one.
I share the general notion that swap-space is a good idea to give the machine somewhere to "park" stuff.
But, these days, sometimes a computer "just has so damned much RAM available" that it will never run out of that resource doing whatever it's tasked to do.
The problem is, if the computer has no means to swap, it has to bring out the dreaded "OOM Killer."(He's the system process with the black robes and the scythe ...) As we all know, Mortis will get the job done, but he can be very indiscriminate.
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
i?e been running myh system with no swap for a few years no and not had any issues. I can run the latest gams (well, such as Linux allows) and have VMs going but still not use all my RAM.
swap is used for either emergency situations where you see it filling then kill a process or where you can't afford RAM.
I refer to desktop use above -- for servers it's similar but money comes into it too.
If you wish to run a diskless system, do so. If I had such and wanted to see if swap was necessary I'd allocate some zram - that's compressed swap in RAM, all managed by the system.
Keep an eye on it, and if never used you could even delete it and reclaim the RAM. Personally I'd probably keep it.
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
Quote:
Originally Posted by sundialsvcs
If Linux has swap space available, it will sometimes "swap out" processes that aren't doing anything – of which there are sometimes a great many.
When a system has relatively little RAM, yes, but even on my low-RAM system I see this only minimally and it's largely pointless as there's still RAM to spare. I can see servers getting the benefit if they're using all the RAM for cache, for example, but I've never seen a situation on a desktop where it makes sense.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.