LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 02-23-2007, 05:32 PM   #16
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209

Quote:
Originally Posted by Quakeboy02
I read a bit of that thread on swapping. It got old after awhile, and I think the bit that I read must have been out of date as compared to current kernels. I don't buy the full memory theory. Things have simply changed. http://gentoo-wiki.com/FAQ_Linux_Mem...2.6_kernels.29

If you simply MUST have a swap space, then spend another $100 on a 1GB stick, and put your swap space on a RAMdisk. If that doesn't make sense to you, then you understand why the need to have a swapspace on disk makes no sense to me.
Good point. But I look at it this way. Swap space is like RAM. It Dosen't hurt to add it
 
Old 02-23-2007, 06:54 PM   #17
Hitboxx
Senior Member
 
Registered: Mar 2006
Location: India
Distribution: Fedora
Posts: 1,562
Blog Entries: 3

Rep: Reputation: 68
The swap is hardly used on my system, its just for namesake.
 
Old 02-23-2007, 07:03 PM   #18
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If you have a laptop and want to use the sleep feature, you will need to have a swap partition. I don't know how large you will need to make it, but I suspect that it needs to be a little bit bigger than the ram on your system.

Hard drive space is a lot cheaper than ram space, so you can easily spare a gig or two of drive space these days. Today, a better rule of thumb for the average computer might be to use the same size of swap as you have ram, then sometime later when you find yourself using a number of programs at once, check what the swap memory usage is.

Last edited by jschiwal; 02-24-2007 at 06:55 PM. Reason: ram -> disk space correction.
 
Old 02-24-2007, 06:49 PM   #19
dasy2k1
Member
 
Registered: Oct 2005
Location: 127.0.0.1
Distribution: Manjaro
Posts: 963

Rep: Reputation: 36
i have 2G ram and 2G swap,
some programs seem to swap themselves out when idle to free up RAM

a great idea if ever i saw one
 
Old 02-24-2007, 08:09 PM   #20
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Quote:
Originally Posted by dasy2k1
i have 2G ram and 2G swap,
some programs seem to swap themselves out when idle to free up RAM

a great idea if ever i saw one

That's a good point too! Why waste RAM on a proccess that is idle?...Also I don't know if it's true an ALL distros...or even on Fedora 6. But when I instaleld Fedora 5, I wouldn't let me go on until I made a swar....it MADE me add swap space before I could install....
 
Old 02-24-2007, 08:19 PM   #21
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
"That's a good point too! Why waste RAM on a proccess that is idle?"

Another point is why waste TIME paging a process out merely because it's idle? If memory's precious, sure, it's a no-brainer. But, if the machine has a couple gig of memory and most of it's free, what's the point?
 
Old 02-24-2007, 10:30 PM   #22
AdaHacker
Member
 
Registered: Oct 2001
Location: Brockport, NY
Distribution: Kubuntu
Posts: 384

Rep: Reputation: 32
Quote:
Originally Posted by Quakeboy02
Another point is why waste TIME paging a process out merely because it's idle? If memory's precious, sure, it's a no-brainer. But, if the machine has a couple gig of memory and most of it's free, what's the point?
There would be no point, which is why the process won't be swapped out. Then again, because the kernel will try to fill up as much RAM as possible with cache, your system will typically have little or no truly free memory.

That's where the performance gain comes in. With no swap, that process that's been idle for the last three days has to stay in memory. With swap, you can move it out so you can get faster access to that data you were just working on 30 seconds ago. It's not a waste of time because swapping out the idle process gives another process faster access to its data.
 
Old 02-24-2007, 10:48 PM   #23
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
Have you guys read this article on swappiness? This is a gentoo wiki page, but I believe it applies to all 2.6 kernels.

http://gentoo-wiki.com/FAQ_Linux_Mem...2.6_kernels.29

I've got 2GB on this machine, plus a 627MB swap space. I don't think I've ever seen the swap above 76K which is what it boots with. Memory usage rarely goes above 200-250MB, either. My problem here, I guess, is that I don't have anything to run that would cause this system to start swapping. I've got 2 kernel compiles and gimp running, along with Firefox and Gnumeric. Used memory is more or less 250MB, and used swap stays at 76K.
 
Old 02-25-2007, 08:09 AM   #24
AdaHacker
Member
 
Registered: Oct 2001
Location: Brockport, NY
Distribution: Kubuntu
Posts: 384

Rep: Reputation: 32
Quote:
Originally Posted by Quakeboy02
Have you guys read this article on swappiness?
Yes, but that link is about tuning when the kernel swaps. I don't see how it lends any support to the "swap is unnecessary" theory. Perhaps you could elaborate?

Quote:
I've got 2GB on this machine, plus a 627MB swap space. ... My problem here, I guess, is that I don't have anything to run that would cause this system to start swapping.
Well, you could always send some of that extra RAM my way. I only have 512MB of RAM and 267MB of my 1GB of swap is currently in use.

It sounds like you genuinely have more RAM than you can use, so you need little if any swap space. That's fine, but it doesn't tell us anything about whether or not other people need swap. For someone who has 1GB of RAM and uses more of it, swap might be helpful. It all depends on the user.

In general I'd say, "When in doubt, have swap." At current prices, a swap partition/file that's double your RAM will cost less than $3.00 in disk space. Worst-case scenario, it eats up some disk space that probably would have been unused anyway. And if you later find you don't need it, you can always reclaim the drive space, so no harm done.
 
Old 02-25-2007, 11:13 AM   #25
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by Quakeboy02
"That's a good point too! Why waste RAM on a proccess that is idle?"

Another point is why waste TIME paging a process out merely because it's idle? If memory's precious, sure, it's a no-brainer. But, if the machine has a couple gig of memory and most of it's free, what's the point?
It still may be better used for caching files for
some other process(es) than having something that
was idle for a long time resident in RAM.



Cheers,
Tink
 
Old 02-25-2007, 12:54 PM   #26
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
The maximum amount of swap space that can be allocated at once is a little less than 2 GB. If the computer has 2 GB and you are using the formula 2 X RAM_SIZE = SWAP_SIZE, creating a swap partition of 4 GB in size will not work. You need to create multiple swap partitions to hold 4 GB of space. It is not bad to create multiple swap partitions, but can be helpful to create instant RAID-0 to increase throughput when Linux needs to dump a lot of data at once from RAM to swap. To create instant RAID-0 with swap partitions, make sure the swap partitions are on separate IDE channels, size of the swap partitions are the same size, and the pri or priority value is the same value.

Swap is necessary because if Linux runs out of memory, it will be unresponsive until it gets more memory.

BTW, The majority of my RAM that is taken up is cache and buffers.
 
Old 02-25-2007, 01:51 PM   #27
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
"Swap is necessary because if Linux runs out of memory, it will be unresponsive until it gets more memory."

Yes, agreed. But, let's consider: If you have 256 MB of RAM, you'll probably have 512MB of swap space. You're going to run out of memory at 768MB; period. If you have 2GB of memory and no swap space, 768MB is only a small percentage of your total memory availability. The 2GB machine will still be purring along when the swapping machine is thrashing itself to death.

When we're talking about small memory space machines, then, yes, swap is an issue that needs to be taken into account. However, when we're talking about a home vanity machine, swap is not an issue, because the memory isn't sized according to the process needs; it's sized according to the ego and wallet of the owner. Unless I start messing with something that takes a serious amount of memory, something that, I will note, would be UNRUNNABLE on a machine with 256MB RAM and 512MB swap, then I simply do not need swap. It will never be used unless I start monkeying with kernel variables.
 
Old 02-25-2007, 02:24 PM   #28
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
AdaHacker says:
Quote:
Well, you could always send some of that extra RAM my way. I only have 512MB of RAM and 267MB of my 1GB of swap is currently in use.

It sounds like you genuinely have more RAM than you can use, so you need little if any swap space. That's fine, but it doesn't tell us anything about whether or not other people need swap. For someone who has 1GB of RAM and uses more of it, swap might be helpful. It all depends on the user.
Now, this I can agree with! It all depends on the user. In your case, if you added another 512MB stick of RAM, your swap would go away. If someone has a laptop with 168MB of RAM, then they have my sympathy all the way around. Not only is the system bus on a laptop probably miserably slow, but the disks are generally only 5400RPM and doing anything serious under those circumstances is miserable.

At my point in life, it's no longer exciting to see the hard disk thrashing away swapping things in and out of memory. I want the command to finish as soon as possible; preferably before I finish pressing the enter key. Large amounts of memory go a long way toward accomplishing that desire. A motherboard with a fast bus and quick drives helps, to.

To sum it up: I don't have a problem with swap space. What I do have a problem with is the knee jerk reaction, by some, that you have to have twice as much swap space as you do RAM. 'Tain't so for large memory machines. If you've got more memory than you'll ever need, you don't need no steenkin' swap. If your needs grow, it's easy enough to add swap later. But, really, sit down and ask yourself: "Self, are you going to run anything or any set of things that will need more memory space than you put in the machine?" If the answer is no, then swap is irrelevant.
 
Old 02-25-2007, 04:16 PM   #29
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
Quote:
Originally Posted by Quakeboy02
"Swap is necessary because if Linux runs out of memory, it will be unresponsive until it gets more memory."

Yes, agreed. But, let's consider: If you have 256 MB of RAM, you'll probably have 512MB of swap space. You're going to run out of memory at 768MB; period. If you have 2GB of memory and no swap space, 768MB is only a small percentage of your total memory availability. The 2GB machine will still be purring along when the swapping machine is thrashing itself to death.

When we're talking about small memory space machines, then, yes, swap is an issue that needs to be taken into account. However, when we're talking about a home vanity machine, swap is not an issue, because the memory isn't sized according to the process needs; it's sized according to the ego and wallet of the owner. Unless I start messing with something that takes a serious amount of memory, something that, I will note, would be UNRUNNABLE on a machine with 256MB RAM and 512MB swap, then I simply do not need swap. It will never be used unless I start monkeying with kernel variables.
Do the following test and see if your system can handle with out swap and assume RAM capacity is 1 GB.

1) mount shmfs with the size of 2048 MB.
2) mount /tmp and bind it to /dev/shm. Also set permission to 1777.
3) Download source code of WINE.
4) Decompress WINE to /tmp
5) Start the compiling process of WINE.

Soon you will experience Linux is not responding.

This is a bad case scenario, but you eventually need swap.

If Suspend to RAM is used, taking the amount RAM and then double it for swap space is a good start. More may need to be allocated if you are intend to upgrade the RAM in the future.

Though it comes down to planning the partition scheme so the amount you provided for swap and other partitions is what you are stick with unless you do not mind backing up your data to resize the partitions to better suit your setup.
 
Old 02-25-2007, 04:38 PM   #30
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
"This is a bad case scenario"

No, it's just a bad example. What you are describing is a test that won't run on a system with 1GB ram and no swap and trying to draw implications from that against a 1GB system with swap. Do the test case between a) 1GB ram and 1GB swap vs b) 2GB ram and no swap. You will be much happier with the 2GB ram system under all circumstances, including those where you have to add swap, than you will be with the 1GB system running identical processes. The important thing for judging what mix of processes can be run at the same time is RAM plus SWAP. A system with 3GB RAM will run the same mix of concurrent processes as a system with 1GB RAM and 2GB swap. But, you won't be happy with any machine that has 2GB swapped out.

Added:
In the mid 90s, I had the good fortune to move from ACP/TPF (Airlines Reservations Programming) to the Open System department (Unix). I wrote an application to replicate the online res system passenger records on a Unix machine. The records came to my system as tape dumps. I couldn't rely on order, so I did an in-core (swap space, actually) sort of the data before doing the database updates. I well remember what it was like to run a small memory system with a large swap space.

Last edited by Quakeboy02; 02-25-2007 at 05:03 PM.
 
  


Reply

Tags
gb, partitioning, ram, swap



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
Not using RAM and Swap much ? ruwach Linux - Hardware 2 06-11-2004 07:26 AM
RAM and Swap shiny_spoon Linux - General 5 01-13-2004 02:27 PM
No SWAP but all RAM!! hari_seldon99 Linux - General 3 01-13-2004 10:48 AM
why swap should be twice of RAM? whitefox Slackware 17 04-19-2003 02:51 PM
Swap and RAM ? mikeshn Linux - General 1 09-18-2002 09:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:04 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
Open Source Consulting | Domain Registration