AuthorTopic: Lessons in swap space (Read 4540 times)

After nearly 18 years of administering various Linux systems, one would think that I know something about setting up a swap partition. So the rule is 3 times your physical memory. Why oh why did I think 20x would be a good idea?

Just finished setting up the last HP Vectra I had on the shelf. I've given away 35 out of the 36 I was given. Each one of them with a fresh copy of VL on them. Starting with VL 5.8 Gold. Each time I broke out a calculator and figured 3 x physical memory when setting up the swap partition. This time I only had 128 MB of pc100 memory left. So I came to the conclusion that 2048 MB swap would be a good idea. Seems funny now.

After three days of fighting with a system that took 12 minutes to load google.com, took 8 minutes just to log out of tty2, I finally figured out the problem was this huge swap partition I had created.

swapoff -athat helped a lot. I was then able to slapt-get --install gparted. With gparted now up and running I just did a quick and dirty resize of the swap space down to 384 MB. That was a lil painful in that gparted really needs more than 128 MB to run on x. But I sat thru it till the changes were committed. Didn't even bother to shut down gparted before I switched to tty2 and turned swap back on with

swapon -aSeveral minutes went by while memory management straightened itself out. The system gradually started to respond again. Then bam, right back up to normal speed! That was a painful lesson in swap space. Don't think I will ever be doing that again.

thx for the wb stretchedthin. with more physical memory available, 2x is enough. this one is critically low so 3x is needed, but can't do more than that. seems the problem is that the memory manager uses physical memory to map the swap space, i didn't have enough physical ram to map that much swap.

After nearly 18 years of administering various Linux systems, one would think that I know something about setting up a swap partition. So the rule is 3 times your physical memory.

Whoa! I wouldn't call "3x your physical memory" a rule. I've *never* made a swap partition that large in 10 years of using Linux. I do have about a gig of swap on my lowest-RAM computer (512 megs); on my 1gig of RAM computers I have 512 megs of swap, and the same on my 3 gigs of RAM computer.

I don't object to the size of the swap partition you finally settled on, but I do challenge the "rule" designation, which I think might mislead users.--GrannyGeek

I usually make a 2x RAM swap partition ... I don't see that 3x would hurt, but if you have enough actual RAM, you can do without swap completely. What I don't understand is why it's bad to have too big a swap partition. brokndodge, are you saying that if you make a huge swap partition, then since physical RAM is used to map it, it takes that much more RAM to map if the partition is bigger?

Logged

"I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones." - Linus Torvalds, April 1991

Makes some compelling arguments for having a LARGER swap space, contrary to what many seem to think should be the norm. Especially with the newer kernel and its abilities to handle swap files more efficiently.

Makes some compelling arguments for having a LARGER swap space, contrary to what many seem to think should be the norm. Especially with the newer kernel and its abilities to handle swap files more efficiently.

I didn't see any compelling arguments, just some info about what swapping does and why more space than you think you need might be a good idea. The thing is, if you have any amount of swap space set up and it's NEVER, EVER used (as is the case on my systems), what's the point of having more? I think some swap space is a good idea precisely because the system is set up to use it in the way described in the article, but that assumes the system *needs* to swap something out or would benefit by swapping something out. If you check frequently and find that no matter what you do, your swap usage is 0, I don't think you benefit by having lots of swap space.

There is one thing that requires swap space depending on how your system is set up. If you have a system crash, information can go into a memory dump that is stored in the swap space. This can then be analyzed to see what might be going wrong. The space has to be large enough to contain everything that's in your memory, so if you have 6 gigs of RAM you'd need at least 6 gigs of swap space. However, since ordinary mortals can't figure out what such a file is telling you, for a regular user there is no benefit. So a system can be set up to NOT save such a memory dump. In that case, the swap space is not needed for that. I'm almost 100% sure that VectorLinux does not do a memory dump in case of a system crash. Do remember that I don't understand any of this and am just repeating what I've heard.--GrannyGeek

For a newer system, one could make the argument that a swap partition was not needed, especially for those systems with large amounts of RAM. And for the majority of users, this indeed could work for them as most users don't really use their PC to its full capacity. However, there are some of us that tend to wring out every ounce of power from their systems with some applications and games which would necessitate a hefty swap file. On the notebook, I've always allocated at least 1GB of swap space, and there's been a couple of times where I wished I had given a lot more. Going to reinstall VL7 later this week and redo the SWAP partition, giving it around 8GB of space. I'll modify how often it's accessed and then see if I can squeeze just a wee bit more out of this poor ol' notebook.