[SOLVED] Swap partition size: huge; any adverse effects? Debian
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.
Swap partition size: huge; any adverse effects? Debian
Hi there,
what (I think) I know is: generally speaking you don't need much swap (about 2x your memory should suffice). If you need more, the sane thing to do is buy more RAM.
Insane situation here Old PC. Challenge: build Linux system that works (slightly?) better than Windows system, with same programs.
In Windows I have seen in rare cases that the virtual memory reaches about 10.0GB(640M of RAM ) The system bodges up, but after an hour or so, when the memory load subsides, at least your work isn't lost.
Three questions:
Can I expect our 'exceptional use' to require as much swap on Linux as virtual memory on Windows?
Would there be some adverse effect of setting up too large swap, excluding the disk space lost? (e.g. swap management taking up RAM)
Would Linux (Debian) actually be able to address so much swap?
Most stuff I read is about 7 years old. (My hardware is older, but my software isn't :P )
It might be tempting for people who love Linux, and have great computers to just say: "Linux is better than Windows" and "do the normal thing". Please refrain from saying so, without good reasoning. Help appreciated.
P.S.
OK, have to be honest. I already partioned for 14GB swap. If I understand the little meter in the lower right corner of my WM correctly it uses almost all of that space... constantly Either my interpretation of 1400.99/1400.56M is wrong, or this could already be such an 'adverse effect' or it could be the systems way of saying: "there's no way I'm using that much swap".
The largest potential swap usage depends on page size - which depends on architecture. Let's see the output of "swapon -s".
Generally on 32-bit systems you are better off having multiples of 2 Gig swap partitions.
I don't really know how much swap you can use, but I don't think swap handling in itself takes much memory. Just my guess though.
10 GB used in Windows sounds weird to me?
I haven't seen so much memory used on any ordinary home/office pc, even when editing movies 2 GB of RAM is enough to work at a decent pace.
In Linux, one tip is to check your memory (no, the computers memory - not your own! ) with the command "free".
Output like this:
(That buffers/cache - it is memory reserved by the system but not actually used.)
Now to be able to answer better, I must know more about your system.
What do you use it for?
How much memory does your programs actually require?
How big harddisk do you have?
If I understand correctly your computer has 640KB ram, is that correct?
What else does it have, mainly cpu, video.
The reason I'm asking is that there is more than memory management to take into account here, in order to get your system to run smoothly - I do know you asked about swap specifically, and hope I/someone can answer that in a good way, but still the bottom line in your question is "build Linux system that works (slightly?) better than Windows system, with same programs."
Things to consider:
* Build your own kernel - pretty important!
* Put swap as the first partition on the disk
* I read some time ago about swap being slightly faster if whole swap is on a separate disk, can't say whether that is true though.
Also don't know if it's best to spread swap on several disks - theoretically it should be slightly better but I never tried it.
Filename type free used priority
/dev/sda3 partition 1434616 0 -1
Typed over from virtual terminal logged in as root... that's bad, right?
Quote:
If I understand correctly your computer has 640KB ram, is that correct?
Heck, no! 640MB. Wait... I'm mistaking: that's the other PC...
Quote:
* Build your own kernel - pretty important!
* Put swap as the first partition on the disk
* I read some time ago about swap being slightly faster if whole swap is on a separate disk, can't say whether that is true though.
Also don't know if it's best to spread swap on several disks - theoretically it should be slightly better but I never tried it.
1: can't wait 8-) ( But really should. Really should! :-X )
2: impossible: multiboot with windows. It's the last partition. IIRC that is fast too.
3: separate disk is understandable and feasible. The whole splitting stuff seems overkill IMHO. Though, it might be faster in theory [reconsidering]
I can't remember the specifics of this system. I believe this is a 1.4GHz pentium II, Geforce2 AGP so crappy it doesn't even have a label, 40GB HD x2, 374?MB DDR1 memory.
(I also plan to install on a better PC.
AMD 900MHz (No SSE), Geforce4 440-SE 64MB AGPx4 640MB DDR2 memory.
)
to put it simply, your machine is using 0MB of swap... the rule with virtual memory and swap generally is between 1.5 to 3 times the amount of RAM you have as the addressing needs to be stored taking away from RAM and pushing slightly more on to Virtual Memory or Swap, now I am not as familiar with swap as Virtual Memory but I know using too much virtual memory can actually slow a machine down, not sure if that's true with Linux and Swap but it wouldn't surprise me.
To put it in simpler terms you should have your swap somewhere between 960MB and 1920MB. I'd probably personally advise ~1536MB (or ~1.5GB) tho 1280 might be an alternative.
As for Windows, Windows reserves memory for future use, the large usage you are probably seeing is nothing more then reserved memory rather then used and so it'd probably drop if you dropped the virtual memory back to realistic figures. Else wise you have a lot of junk on your windows box that really needs cleaning out.
Last edited by r3sistance; 05-07-2011 at 10:32 AM.
the rule with virtual memory and swap generally is between 1.5 to 3 times
May I ask where you have that "rule"from. Sorry I have to say that, but in my eyes this is just nonsense. The amount of swap that you need is only dependent on one thing: The workload of that machine. There are no general rules to determine the amount of swap you should setup. Just an example: While I set up 8GB of swap on my workstation with 8GB physical RAM (because I sometimes run many VMs simultaneous), I only have set up 2GB of swap on my laptop with 4GB physical RAM (which I mainly use for surfing the net and as multimedia machine). I don't see why I should set up 6 to 12GB of swap on this machine, it will never be used.
May I ask where you have that "rule"from. Sorry I have to say that, but in my eyes this is just nonsense. The amount of swap that you need is only dependent on one thing: The workload of that machine. There are no general rules to determine the amount of swap you should setup. Just an example: While I set up 8GB of swap on my workstation with 8GB physical RAM (because I sometimes run many VMs simultaneous), I only have set up 2GB of swap on my laptop with 4GB physical RAM (which I mainly use for surfing the net and as multimedia machine). I don't see why I should set up 6 to 12GB of swap on this machine, it will never be used.
The rule generally comes from years ago actually, modern day machines are able to run much more effectively off of RAM (because of both more RAM and better optimized code) however back say 10 years ago, that was barely even possible. So in the future it might be a case machines need none at all. It is as you say possible to run with much less, it is also possible to run with much more, machines on the low-end or even mid-end will however likely still be using Swap or Virtual Memory and as such should be made to use 1.5~3 times RAM as Virtual Memory/Swap. Any larger can actually become decremental to the machine (due to addressing). So yes, it's possible to run with no RAM or Virtual Memory, in the cases of machines reaching these points I don't think the word "general" applies anymore however (the number of laptops around with 512MB~2GB of RAM vastly out-numbers those with 3GB+).
machines on the low-end or even mid-end will however likely still be using Swap or Virtual Memory and as such should be made to use 1.5~3 times RAM as Virtual Memory/Swap.
As I stated above, the amount of swap can only be determined by analyzing the workload. It is not dependent of the class of the machine. A machine that really would need that amount of swap would be awfully slow and not fitting to the job it is doing.
As I stated above, the amount of swap can only be determined by analyzing the workload. It is not dependent of the class of the machine. A machine that really would need that amount of swap would be awfully slow and not fitting to the job it is doing.
There should not be too many issues with the sizes I stated, having 1.5~3, there are number of things that could use such without being sluggish or slow, it depends on the tasks themselves. Still 1.5~3 tends to be about the best area for most general machines, high-end machines can get away with none but even mid range machines can be pushed by some tasks.
I'm with TobiSGD -- a system needs as much swap as it needs and there's no rule that can predict it. Years ago these "swap must be x times RAM" rules appeared but had no basis in practice; nonetheless they persist and it's about time they were consigned to the Bothers Grimm of computing.
If the system uses swap then it is performing slowly and ideally more RAM would be fitted. If you are lucky enough to be able to fit more RAM then swap can be seen as a safety net -- it avoids the messy situation of running out of virtual memory and allows you (by checking to see how much swap is actually being used under a variety of load scenarios) to decide how much extra RAM to get. One easy way to see how much swap you need is to use a file for swap instead of a partition -- it will grow to accommodate what you use.
If you plan to hibernate a system then different swap considerations apply.
On a system with 4 GB RAM, I sometimes run three or four VMs, configured with 1 GB each. That causes swapping but I rarely run so many VMs simultaneously so the swap is needed and the cost of more RAM (in cash and carbon) is not justified. GKrellM nicely shows how much swap is being used at any time.
Thanks for all the replies. Indeed I've read somewhere that the "2*RAM-size-rule" was just an easy way of explaining all the factors involved.
By the way I counted wrongly It's 1.4GB of swap I have. That is very reasonable. It is funny however, that no-one can actually confirm the adverse effects of setting too much swap.
As far as I know, that old rule "swap=2xRAM" (or 3x) comes from the old era of personal computers with 128 or 256 MiB RAM. The RAM was very expansive, the hard disk space was (and is) much cheeper. Of course, more swap use means more hard drive load and more CPU load. Rich people could afford more expansive hardware! So, why not 4x or 5x? Because in such cases the work to do would be so big that a more powerful computer was needed!
There is a different approach in m$windows, I think. The virtual memory is used always, even when the memory used is less than the installed memory. There is a reserved disk space, usually in the same drive as the system, in the hope to have a consecutive disk space and avoid fragmentation of the swap file. However, if you increase the memory allocation, the operating system expands this disk space, of course in other parts of the disk space (so, the swap file becomes fragmented). Older (at least) specification was that the virtual memory could be up to 4 or 5 times the installed RAM. I don't know actual specification; but please note that at the time, RAM size was mostly up to 256 of 512 MiB, so 4-5 times RAM was within the addressing space of the 32bit mswindows system (that is 4GiB minus video card memory & firmware memory space; i.e. something like 3GiB+ ).
Nevertheless, I had myself painful experience with such big virtual memory size: this was in case of many running programmes & big cad models. The response of the machine was veeeeeery slow. Sometimes this geant memory allocation (up to 1.6Gib with 500MiB installed physical RAM) was due to malware infection. To change from a displayed window to another or change a web page could take 5 minutes or more.
I think that in the case of Linux, the swap space is used in addition to the physical RAM, not in parallel. I mean that 1GiB RAM + 1GiB swap cover 2GiB total space.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.