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!
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.
I have linux installed with 2.5GB and SWAP with 5GB
my question is : if all processes consume my physical memory can i divert process request to my SWAP, so that my system performance will boost up
Does this mean that your root partition is 2.5GB and swap is 5GB?
What distro are you using? and how did you end up with a 5GB swap? How much RAM do you have?
You should not need 5GB of swap. But, to answer your question, all linux distros I have tried will automatically use all your physical RAM before turning to swap. Then after all your RAM is used up linux will start to use your swap.
To check how much RAM and swap you are using, open up a terminal and run:
Code:
free -m
(This displays your memory usage in megabytes).
You will get something like this:
This means I have 2GB (2026) RAM, and I am using 812mb with 1213 free. But note the -/+buffers/cache line. This shows that 332mb are being used by programs, with 1693 free. The buffers + cached columns on the right show how much of that 812mb that is being used is cached in memory. So 332 + 125 + 354 = (approx) 812. And I am not using any swap.
That is SWAP it's all about (well, almost). BUT: because runing on a hard-disk, SWAP memory is very slow and, the more swapping that occurs, the slower your system will be.
Anyway, why are you having a 5GB SWAP partition?! It's huge!!! In "old times" when RAM memory was a problem, there was the recommendation that you should make a partition that would be (in size) not more than double of you RAM memory. That would be more than sufficient. I'm a newbie so, for more accurate information, googlize. Read this: http://www.linux.com/feature/121916
my question is : if all processes consume my physical memory can i divert process request to my SWAP, so that my system performance will boost up
Performance won't boost when system is using swap. It will drop instead (well, unless your swap on solid state drive) - because accessing harddrive is much slower than accessing memory.
Usually it is advised to make a swap partition twice the size of your ram.. My RAM is 1GB and am having 2GB swap..
Who advised you to end up with a 5GB swap?
Access to RAM is much more times faster than to Swap.. The more process in your swap the slower you system and the more you have physical memory the faster would be you computer.. I think you should consider a new RAM rather finding a process switch temporary fix...
I personally think that the "swap = 2x RAM" rule of thumb is a good one, basically in-part because both of these resources are cheap.
The original complaint is "system performance needs to be boosted up." This alone does not necessarily have anything at all to do with the amount of swap-space that you have.
The ordinary purpose of swap-space, today, is "a place to set things down." Most computers these days have more-than-adequate supplies of RAM, as your machine certainly does. But the operating system may nevertheless find that it wants to use some portion of RAM for other purposes, but there's this chunk of written-to storage that's "in the way." Where do you put it? You swap it out.
One of the things that the operating system loves to do is to fill-up RAM with file buffers. These are chunks of data that someone has read, and that someone might need to read again. (This is often the case.) Chunks of written-to storage that have become "long in the tooth" get moved out of the way sometimes to make room just for that.
If "performance is sluggish," the first thing to check is your disk I/O: that DMA is being used, and all of the hardware features of your controller are being exploited. On my desktop systems, I don't use the motherboard's disk-controller; I have an expansion-card. A very high performance controller costs about $40 and "it do make a difference."
I personally think that the "swap = 2x RAM" rule of thumb is a good one, basically in-part because both of these resources are cheap.
I agree, but use caution. I tried to do a RHEL5 install not too long ago, and tried to do this (set the swap to be 8 GB...long story, has to do with an Oracle DBA and her whining about how it 'had to be' that way), on a system with 4GB of RAM. Swap set above 8 GB caused the install to take a LONG time (like 6+ hours), before it died. Reduced swap to 4GB, and install was less than an hour.....
I agree, but use caution. I tried to do a RHEL5 install not too long ago, and tried to do this (set the swap to be 8 GB...long story, has to do with an Oracle DBA and her whining about how it 'had to be' that way), on a system with 4GB of RAM. Swap set above 8 GB caused the install to take a LONG time (like 6+ hours), before it died. Reduced swap to 4GB, and install was less than an hour.....
For 4GB RAM, swap should be ~3GB... for most situations. Anyway, how do you explain the 'LONG time'?
Does this mean that your root partition is 2.5GB and swap is 5GB?
What distro are you using? and how did you end up with a 5GB swap? How much RAM do you have?
I think he meant 2.5 GB RAM and 5GB SWAP. I presume he's applying the infamous 2x rule.
Quote:
You should not need 5GB of swap. But, to answer your question, all linux distros I have tried will automatically use all your physical RAM before turning to swap. Then after all your RAM is used up linux will start to use your swap.
It's long since the last time I looked into it, and the kernel has changed greatly in the latest months, so I am not sure how it handles it right now. But if the thing hasn't changed so drastically, this is controlled by a thing called swapiness.
Also, the kernel uses swap for several things. You might find a few kilobytes or megabytes of swap filled at any random moment, even if your ram is empty.
Quote:
Originally Posted by ErV
Performance won't boost when system is using swap. It will drop instead (well, unless your swap on solid state drive) - because accessing harddrive is much slower than accessing memory.
Exactly. Swap is not and was never a performance booster. It's just a fallback that will prevent your kernel from randomly closing programs once your ram is full. Lately it's also used by some hibernation methods to store the contents of your ram for later restoration when you want to go back on from hibernation.
Nothing in a tipical pc is faster than ram, nothing except for the l1 and l2 caches, that live inside your cpu. Regular swap on hard drive is in the range of tens of millions slower than these of the ram (tens of miliseconds seeks time vs. a few nanoseconds for ram).
Quote:
Originally Posted by sundialsvcs
I personally think that the "swap = 2x RAM" rule of thumb is a good one, basically in-part because both of these resources are cheap.
Except that by the time you are using 1GB (let alone 5) your system will be unusable. Then you will wish you had a smaller swap space so the program that's leaking ram is forced to be closed and you can continue working after a reasonable amount of time.
If the swap space is too big and something start leaking swap you can wait sitting for a couple of days
Quote:
The original complaint is "system performance needs to be boosted up." This alone does not necessarily have anything at all to do with the amount of swap-space that you have.
It's the other way around. If you really need 5 GBs of swap, then simply your machine can't do the job you need it to do, and a hardware upgrade is mandatory.
Having some swap space never hurts. Having so much can be a problem, unless you can guarantee that nothing will ever lack memory in your system. However on modern desktops that's no longer possible, overall if you want to use the latest and greatest.
For 4GB RAM, swap should be ~3GB... for most situations. Anyway, how do you explain the 'LONG time'?
I don't...I just know what it did. Never pursued it more, since I got the build done, and things working. And I agree with you, but set the swap to 4GB to shut the aforementioned DBA up.
This is the same DBA who says:
"QuickIO or ASM is totally unnecessary, for any database less than a terabyte"
"You need to try to keep a database on one disk, so access is quicker.."
"Anything less than 12GB of RAM won't even let Oracle start the listener...".
I personally think that the "swap = 2x RAM" rule of thumb is a good one, basically in-part because both of these resources are cheap.
It depends on what you use your machine for. I have 2 gigabytes of RAM and 1 gigabyte swapspace. Normal swap usage is zero, or less than megabyte. Sometimes system use few dozen megabytes, but not more. I don't remember situations when swap file usage was at least 300megabytes. So if you have decent amount of RAM, large swapspace will be a waste of resources(unless you are really doing something heavy that can't live without a lot of swap space). I remember that somewhere I saw recommendation that "swapspace should be twice the amount of RAM, but not more than 512 megabytes". I don't remember where I saw it, but slackware 11 was happily working with 512mB of swap and 512mB of RAM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.