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 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
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.
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....
"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?
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.
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.
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.
"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.
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.
"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.
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.
"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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.