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.
It isn't terrible at all. I'm assuming you really mean you have 256MB of RAM (I've never seen a configuration with 260MB. 256 * 1024 = 262144).
The general rule of thumb is to have twice as much swap space as RAM but not more than 2GB (although this limit is increased in recent kernels). I would recommend a 512MB partition under your current conditions.
Swap doesn't take the place of RAM. Adding more RAM will still speed up your system, however you should increase your swap space if you add RAM. This can be either a swap partition or a swap file. It is often easier to add a swap file than it is to try to resize a partition. A swap file will not be quite as fast as a swap partition, so if you are planning on adding RAM in the near future, go ahead and make the swap partition large enough to handle your planed size.
"Technically, twice your RAM is what you need for swap."
Sorry, but this is simply not true. Swap is a logical extension to RAM. If you're not doing anything that takes more RAM than you have in your machine, then swap is superfluous. Think about it: if you spend big bucks on another 1GB of vanity RAM that you don't need, why would you need to add swap space?
For most home users, a minimal amount of swap is all that's needed; minimal as in a few hundred MB, and you'll probably never see even 1MB of that actually being used. However, if you're a laptop user and have limited RAM then you may need to have more swap space. If you are doing video rendering or running extremely large computational spreadsheets then you may need more swap space. If you have 1GB of RAM and your usage is limited to browsing, watching movies, and doing your checkbook, it's unlikely you need any swap at all.
The amount of swap needed is not a function of the amount of RAM you have. It is a function of the amount of memory usage you have.
I have a friend that sets Linux servers and desktops up for a living, and twice the RAM for swap was what he was told and what he uses. If however, believing a professional is not in your line of interest, go ahead.
"I have a friend that sets Linux servers and desktops up for a living, and twice the RAM for swap was what he was told and what he uses. If however, believing a professional is not in your line of interest, go ahead."
We all do a lot of things that are wrong but inconsequential. The fact that he is a "professional" is of no consequence if he is merely doing things by rote without understanding the consequences of what he is doing.
For instance, one of the drives in my boot array on this (my test mule) system died last night. I spent the night adding the OS (which I had backed up to a tar file 2 weeks ago) to what used to be the "data" array. I have 768MB of RAM on this machine, but I had never put any swap space on this drive. I'm running currently with no swap space, and probably won't add any unless I run into a situation where I need it. However, I do not use the suspend function, and the heaviest workout this machine gets is to compile a kernel and maybe watch a DVD from the network.
Last edited by Quakeboy02; 04-11-2007 at 04:42 PM.
kalabanta and Quakeboy02, you are both correct. If you don't do anything that uses swap, you will never use your swap, and 2xRAM IS the correct amount of swap (I've been installing Unix and Linux systems for over 12 years). The problem is that if you ever do anything that requires you to use swap, and you run out, your system will hang. This could be accomplished by YOU doing something OR by someone else attacking your box. With the price of HD's what they are, creating a partition 2X your RAM is a cheap (read almost nothing in cost) way to increase stability. Just like you hardly ever use all your swap, you probably also almost never use all your filesystem either.
"2xRAM IS the correct amount of swap (I've been installing Unix and Linux systems for over 12 years)."
Then you should know that this rule of thumb came about way back when we measured our memory in KiloBytes. 2xRAM is the *recommended* amount of swap. The *correct* amount of swap is what is actually needed given your situation.
And if you are somehow capable of determining the amount of ram "actually" needed by a perfect stranger with no other knowledge than "My computer has 260mb of RAM. I want it to run as quickly as possible. How much swap should I use?" can you please let me know what tomorrow's lottery numbers will be?
IMHO, it is much better to build a system to be prepared for the unexpected than it is to save half a gig of disk space. If you would rather live on the edge, and tweak your system to only use the disk space you actually need, then go for it. Personally, I have too much to do to constantly watch swap usage on my computers. But, I will concede that you are correct (as I think I already did once), you only NEED the amount of swap that you will actually use. The rest is insurance.
"And if you are somehow capable of determining the amount of ram "actually" needed by a perfect stranger with no other knowledge than "My computer has 260mb of RAM. I want it to run as quickly as possible. How much swap should I use?" can you please let me know what tomorrow's lottery numbers will be? "
Yes, they are pretty much the same question, aren't they? My beef is not with the suggestion that 512MB is a good value so much as with the insistence that it is correct value. Personally, I *believe* that 512MB is probably a good value of swap for the average home user under all circumstances of memory, whether that's 64MB RAM on a laptop or 2GB RAM in a vanity gaming system. Those who run servers know enough to keep a handle on swap usage and adjust memory and swap as needed, so I'm not concerned about them, at all.
I'd bore you with a story of how I used swap in the early 90s to overcome the difficulties of developing programs on a P233 that were going to be run on Sun and AIX systems. But, even my eyes are glazing over at the thought.
For the sake of political incorrectness, I have 384mb of actual RAM, but a swap partition of 1 gig. Thats about three times my RAM, but you know what? That's about how much I need. Right now I'm using 75% of my actual ram and 35% of my swap space. OR 284Mb Normal RAM and 375MB swap. And that's under a pretty minimal load (XMMS, Firefox, and an MSN client)
If you have the space, I would suggest that you use plenty of it for SWAP. It can't hurt anything, and its damn useful when you need it.
What I had read was from non-zero to 3 times the RAM space.
I think the kernel takes the asumption that there is swap. Even a few hundred MB will make it very slow if you have have very few ram but at least it will not crash if no more memory is available.
Over 3 times is probably going to slow down a lot and you should buy ram.
It depends on so many factors that the question about the upper limit has no real answers imo..
The computer I'm on now is about 6 years old I think. But I've had it forever and by now I know the thing inside and out. I might almost be sad when I have to give it up for a new computer this fall...
Well i think the original question was not, can a system run without swap?, or, do i HAVE to use 2wice the amount of ram for swap?, but how much swap do you suggest i use?. So by now it is established that one must set apart enough swap to run the system at the most demanding stages that the machine will be used under. I have 1gb ram and 1gb swap, and hardly ever use the swap, most I've used is about 24mb, and without full ram. With 256mb it is different, he would probably want from about 512 - 1024 mb of ram,but it is really up to each individual person, i think Blah Blah should consider how much swap he thinks he will use, and add a couple hundred mbs just to make sure.
Last edited by mitchell7man; 04-12-2007 at 08:44 PM.