LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 04-11-2007, 05:11 PM   #1
BlahBlah_X
Member
 
Registered: Nov 2006
Posts: 70

Rep: Reputation: 15
Swap


Does swap space work as well as people say it does? Or is it terrible like Windows virtual RAM?

My computer has 260mb of RAM. I want it to run as quickly as possible. How much swap should I use?
 
Old 04-11-2007, 05:20 PM   #2
phantom_cyph
Senior Member
 
Registered: Feb 2007
Location: My HDD...
Distribution: WinXP for designing, Linux for life.
Posts: 2,329
Blog Entries: 1

Rep: Reputation: 47
Technically, twice your RAM is what you need for swap. I think it is pretty good personally...
 
Old 04-11-2007, 05:29 PM   #3
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

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

See http://www.lissot.net/partition/part....html#SwapSize for more info (although, they recommend one times RAM.)
 
Old 04-11-2007, 05:29 PM   #4
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,275

Rep: Reputation: 126Reputation: 126
"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.
 
Old 04-11-2007, 05:33 PM   #5
phantom_cyph
Senior Member
 
Registered: Feb 2007
Location: My HDD...
Distribution: WinXP for designing, Linux for life.
Posts: 2,329
Blog Entries: 1

Rep: Reputation: 47
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.
 
Old 04-11-2007, 05:38 PM   #6
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,275

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

Added:
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 05:42 PM.
 
Old 04-11-2007, 05:43 PM   #7
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
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.
 
Old 04-11-2007, 05:45 PM   #8
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,275

Rep: Reputation: 126Reputation: 126
"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.
 
Old 04-11-2007, 05:58 PM   #9
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
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.
 
Old 04-11-2007, 06:14 PM   #10
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,275

Rep: Reputation: 126Reputation: 126
"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.
 
Old 04-11-2007, 06:35 PM   #11
war1025
Member
 
Registered: Jul 2006
Distribution: Debian: Squeeze AMD64
Posts: 318

Rep: Reputation: 31
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.
 
Old 04-11-2007, 07:10 PM   #12
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 55
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..
 
Old 04-11-2007, 10:17 PM   #13
war1025
Member
 
Registered: Jul 2006
Distribution: Debian: Squeeze AMD64
Posts: 318

Rep: Reputation: 31
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...
 
Old 04-11-2007, 10:27 PM   #14
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,275

Rep: Reputation: 126Reputation: 126
"The computer I'm on now is about 6 years old I think."

Yeah, mine are getting a bit long in the tooth, as well. I lost a drive last night and I noticed it was made in 2001.
 
Old 04-11-2007, 11:55 PM   #15
mitchell7man
Member
 
Registered: Jan 2007
Location: Provo, UT
Distribution: OSX - Fedora
Posts: 458

Rep: Reputation: 31
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 09:44 PM.
 
  


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
how much swap space is needed; how to increase swap space? johnpaulodonnell Linux - Newbie 5 03-23-2007 04:20 AM
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 09:32 PM.

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