How much swap for 4GB RAM, if any?
Slackware 14.0
In the Slackware-HOWTO file, Volkerdi says: "If you machine doesn't have a lot of RAM, you'll want another partition for swap space". Does this mean that if you do (have a lot of RAM) then you do not need a swap partition? I'm installing 14.0 and the machine has 4GB RAM. |
I have 4GB of ram.
I have a swap of 4GB to allow hibernating my laptop, but other than that, it doesn't get used. Obviously, it depends how you use YOUR pc, so maybe set one up & if you find it is not useful, you can remove it later. Or go without, and if it's a problem, add some later. Choice is good :D |
The two choices are in fact one and the same for, if I allocate only 1G thinking I have time later to add 1G more, where do I get that 1G extra once I partioned the whole disk? Unless I add a 2nd disk.
|
You can shrink partitions to make more space.
Its probably easier to just setup 4GB swap space from the start. Unless you've got a small HDD its what I would do. |
Quote:
|
Well, with 4GB RAM and 500GB disk, following a rule of thumb I found somewhere (2 * RAM + 1GB for exceptional situations than can slow down the machine while using GUI) I created 9GB swap. Now, 9 / 500 = 1.8 per cent of total disk, which seems to be steeling it not to much space.
Later on, I'll consider if I shrink it to a smaller size, a thing easily done with (c)fdisk by erasing first the whole partition and then creating it the new size. Thanks for giving your valuable opinion which, on the other hand, matches that of Volkerdi in the Slackware-HOWTO, when he speaks about swap size = RAM size. |
The only reason for a swap partition is to suspend to disk / hibernate. There is no other reason, so if you don't suspend to disk there is no need for swap.
|
Quote:
Quote:
I even have a 1GB swap partition on my main machine with 16GB RAM and it is occasionally used. In short: If you need a swap partition and what its size should be can only be determined by your size of RAM and the workload you intent to run. General thumbs of rule are pretty worthless, but we can give you at least some recommendations from experience. |
Is there a log that monitors swap usage at all?
|
Quote:
A 500GB HDD will actually be about 465GB. Or 465GiB if you like the whole MB/MiB thing. http://en.wikipedia.org/wiki/Mebibyte http://en.wikipedia.org/wiki/Megabyte *edit- the 'swap = 2 x RAM' idea is very old, and there has been people pointing out that for years now- http://www.cyberciti.biz/tips/linux-swap-space.html Every time I see people say that 'swap size should be RAM x 2' I shudder. Its been repeated so many times that its even more annoying to me than seeing people post 'how tos' for debian using sudo commands.... |
Quote:
A valid question is, I think: can too much swap space conspire against system performance? If the answer is "no", what do I lose by using ten times the RAM if my disk has the space? |
Quote:
|
Quote:
|
The reason why I don't use swap anymore is because when the system runs out of RAM, because some program eats it up, I do NOT want my computer to slow to a crawl as it is swapping like mad. I just want it to kill the damn program and let me get back to doing what I was doing. I have messed with the various swap settings and I have decided that having swap in the first place is not very useful and in fact may be wasteful in most cases -- a waste of space and time waiting for your computer to stop swapping. I do not have enough applications running in the background and using any significant amount of RAM. If you run a server, then things may be different, but you will also have a lot more RAM.
My conclusion is for a desktop computer that does not suspend to disk, there is no use for swap. |
I've always been told you takes the RAM size and Double it to get your Swap size.
4GB RAM = 8 GB Swap Partition |
This is what redhat says about swap.
|
Quote:
One could buy a 120GB SSD in that case for swap only. |
Of course more RAM is the only thing better than RAM. If a processor has a physical address space of 2^40 bytes, implementing the whole space (to put 2^40 bytes of RAM on the other side of the bus)is the optimal solution, disregarding money and the physical space to place that much RAM. But the 80286 designers took a lot of work to design the mechanism of virtual addressing. The 80286 (famous AT IBM PC) had a _physical_ address space of 2^24 bytes (16MB). This means the processor effectively had 24 address lines. Now, in those days, RAM _was_ expensive, and nobody would dream of installing the full 16MB in a desktop machine. But there was virtual addressing, which meant full CPU support for memory management and a mechanism whereby the program got the illusion of having a large memory space, larger than the physical one.
So the full concept of the CPU Protected Virtual Address Mode rests upon the usage of large amounts of external memory or swap memory and it seems a bit of an absurdity to end up in a scenario where swap is no longer needed. |
Quote:
OK, a decision about swap has to be made during installation when the memory workload cannot practicably be estimated but it would be nice to give a caveat about the limitations of this "one size fits all" approach and a recommendation to monitor the memory workload. |
Try different sizes or none at all. Remember that you don't need a swap partition, but you can create a swap file instead.
|
All times are GMT -5. The time now is 07:21 AM. |