LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 12-09-2008, 05:23 AM   #1
sunil_sutar
LQ Newbie
 
Registered: Nov 2007
Posts: 7

Rep: Reputation: 0
SWAP


Dear all,

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


Thanks in Advance
 
Old 12-09-2008, 06:02 AM   #2
tommcd
Senior Member
 
Registered: Jun 2006
Location: Philadelphia PA USA
Distribution: Lubuntu, Slackware
Posts: 2,230

Rep: Reputation: 291Reputation: 291Reputation: 291
Quote:
Originally Posted by sunil_sutar View Post
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:
Code:
bash-3.1$ free -m
             total       used       free     shared    buffers     cached
Mem:          2026        812       1213          0        125        354
-/+ buffers/cache:        332       1693
Swap:          996          0        996
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.

Last edited by tommcd; 12-09-2008 at 06:15 AM.
 
Old 12-09-2008, 06:09 AM   #3
sica07
Member
 
Registered: May 2008
Distribution: Arch
Posts: 47
Blog Entries: 3

Rep: Reputation: 16
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
 
Old 12-09-2008, 07:01 AM   #4
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by sunil_sutar View Post
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.
 
Old 12-09-2008, 08:22 AM   #5
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: Slackware®
Posts: 12,541
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Hi,

WOW!

Give us your system specifications? 5GB swap is a big swap. How much memory? What distribution? What are you using the system for?
 
Old 12-09-2008, 09:16 AM   #6
baig
Member
 
Registered: Nov 2008
Location: وادی ھنزہ
Distribution: Solaris 5.10, Debian Server 5.2, CentOS 5.6
Posts: 226
Blog Entries: 3

Rep: Reputation: 38
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...

Cheers!!
 
Old 12-09-2008, 09:54 AM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 7,156

Rep: Reputation: 2204Reputation: 2204Reputation: 2204Reputation: 2204Reputation: 2204Reputation: 2204Reputation: 2204Reputation: 2204Reputation: 2204Reputation: 2204Reputation: 2204
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."
 
Old 12-09-2008, 10:11 AM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,926

Rep: Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690
Quote:
Originally Posted by sundialsvcs View Post
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.....
 
Old 12-09-2008, 10:23 AM   #9
amani
Senior Member
 
Registered: Jul 2006
Location: Kolkata, India
Distribution: Debian 64-bit GNU/Linux, Kubuntu64, Fedora QA, Slackware,
Posts: 2,766

Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
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'?
 
Old 12-09-2008, 10:48 AM   #10
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
Quote:
Originally Posted by tommcd View Post
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 View Post
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 View Post
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.
 
Old 12-09-2008, 10:56 AM   #11
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,926

Rep: Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690
Quote:
Originally Posted by amani View Post
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...".

yeah....right....
 
Old 12-09-2008, 11:09 AM   #12
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Quote:
Originally Posted by sundialsvcs View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SWAP - having trouble with swap auto mounting at boot lostdj Linux - General 2 08-05-2008 01:47 PM
Need Help Increasing Swap by creating a swap file froggo Red Hat 3 06-13-2006 09:04 AM
Linux swap / solaris not appearing as swap in Ubuntu? Erik_the_Red Linux - Newbie 1 07-30-2005 01:57 PM
How to unmount actual swap and mount a new(bigger) swap space? isaac Linux - Newbie 1 06-06-2004 02:23 AM
Difference between Swap Virtrual memory and Swap Parition Nappa Slackware 4 11-27-2003 08:58 PM


All times are GMT -5. The time now is 08:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration