Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
There simply is no logic in having more swap because you have more RAM. Obviously you need more swap if you have less RAM, and vice versa, and of course depending on the task at hand. Of course you may have the space, but these days the moment when you wish you had more available space for storage will come rather sooner than later. Where's the sense in saying 'A has a small box for storing things, so he should have another small box for storing things, while B has a huge box for storing the same amount of things so he needs another huge box because you never know'?
The sum total of RAM plus Swap must be enough to run what you need to run. If the system gets too slow, add RAM. That's all there is to it.
The amount of swap you need with larger amounts of ram is just as relevant as when you have smaller amounts of ram. The swap is there for when you need more space than you have ram. If you have 512megs and you only occasionally use swap, you can get by with 512. If you are using that swap frequently enough that is slows down the system to the point it bothers you or is causing issues, then it is time to increase your ram. Now repeat those last two sentences replacing 512megs with whatever amount of ram you wish. It applies equally well for 512meg as it does for 32gigs. IF you have a great excess of ram (ram is cheap) for your needs, then you could drop back on the amount of swap. There are a lot of people out there that could get by with 512meg but are running 2gb, which is fine. This allows them to essentially never use swap, so dropping back the amount of swap they make available under those conditions is perfectly fine. However, if one regularly uses (say 90% of the time) 3/4 of the 2gb, I would argue that the 2X rule still applies. It becomes extremely useful for that other fraction of time (the 10%) when you are running larger or more tasks than usual.
I don't see anyone arguing with you lazlow. The point I was trying to make is that if you're a relatively new user and you are starting with a 3GB machine, then chances of you needing any swap space are almost zero. Of course, there might be some minority of newbies who will immediately begin with high-end video editing or some other programming that is extremely memory intensive. Generally, though, such users already know they are going to use a lot of memory due to previous experience, and will plan accordingly.
I strongly recommend you have a swap partition even a small one. In many cases it will prevent the system from grinding to a halt when it runs out of RAM. (Yeah sure the OOM killer will help you, but it will still almost freeze before that happens)
Of course the same thing happens once you have filled both RAM and swap. So what you need is a decent sum total, not more swap if you already have more RAM to begin with. If RAM is scarce you need much swap, if RAM is opulent you need less swap, if any.
Here are some articles that may convince you that swap, even a small swap partition is actually useful and a good idea even if you have 64 GB of RAM or more.
Swapping is necessary for two important reasons. First, when the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately. Second, a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache.
As I write this, my 1024MB machine has 184MB of swap used out of 1506MB, and only 17MB of memory free. On old-Unix this would indicate a perilous situation: with numbers like this it would be grinding. But Linux is perfectly happy with these numbers: the disk is idle and it responds well.
The 184MB constitutes tasks that are running in the background, like the getty on the text console, or the gdm login manager. Neither of them has done anything much since I logged in days ago. From a certain overoptimizing point of view I ought to get rid of those tasks — although for the login manager it might be hard. But even then, there's probably lots of memory used for features of programs I am running that don't get invoked very often.
With swap, that memory is written to disk and costs very little. Without swap, it would be cluttering up RAM, as if I was down to only 840MB. Everything else would need to page a bit harder, but it wouldn't be obvious why.
Disk is cheap, so allocate a gigabyte or two for swap.
Well, it seems the issue is a subject of debate, but what they seem to be debating more is not whether to have swap but how often or how much to swap. My swappiness is set to 60 (I think it's the default) and it works fine so far, it's true it rarely uses swap, but in some cases, especially when leaving the computer on for extended periods swap does get used somewhat. And then there are the times when some program decides to use up all my RAM and starts eating up swap ... that would be the time to kill it quickly. I guess it does also buy me some time in such cases.
Anyway, you decide, but I think there are benefits to having a swap partition, more so than not having one.
Well, it seems the issue is a subject of debate, but what they seem to be debating more is not whether to have swap but how often or how much to swap.
That's more or less the same thing, isn't it? If you are of the "swap early" crowd, you'd want to have swap available to keep the memory "pure". If you're of the "swap late" crowd, then memory is where stuff belongs until memory starts getting full. Swappiness is more or less a measure of fullness, and having it set at 60 seems to be a good compromise.
Every rare now and then, I'll see about 180K (not M) bytes in swap. It happens at random, and it sits there until I reboot. I never notice that I have done something different than on any other day. I have 4GB of RAM, which is *way* more than I need.
I concur. To be able to hibernate which means that all memory is copied to swap you need at least as much swap as you have RAM.
Hibernate did not work for me on my ASUS EEE running Ubuntu until I increased the swap from a few hundred megs to a bit over 1GB.
What I am wondering, though, is what would happen if you try to hibernate a state that already uses swap for one or more applications?
Not that it really matters in most cases, but I am curious.