On 14 December 2017 at 22:44, Carlos E. R. <robin.listas@telefonica.net> wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Thursday, 2017-12-14 at 11:17 -0500, David T-G wrote:
Hi, all --
I am finally breaking out my Linux Mag DVD to install on my shiny used laptop, and the partitioner has me scratching my head. I have 8G of RAM, and I gave myself about 17G of swap space when I laid out the disk. The partitioner has a check box for "Enlarge swap for suspend", although it isn't selectable (perhaps because I have my OS partition right behind it?). Sooooo...
How much swap do I need if I'm planning to suspend to disk (aka hibernate as compared to sleep, but I forget the s2/s3/... stages)?
Well, you need as much as you need... :-)
There can't be an exact reccomendation. You initial choice of 17G is fine (it is what I have, more or less). Only experience with your actual usage pattern will tell.
For hibernation you need the same ammount of used RAM + the ammount of already used swap at the instant of hibernation. However, the hibernation image can be compressed, perhaps half.
This instant I'm using 6.1 GB of swa, and a bit under 5GB of RAM, so I might need up to 11GB to hibernate.
Some people say "2 times RAM", but that comes, IMO, from the Windows times when that was the maximum. Others disagree.
I had a Linux system with 20 times at least. And yes, it was actually needed.
Please avoid giving recommendations that imply that more swap is somehow better Setting the swap too large can very certainly cause issues. Consider the following from an old white paper on the topic: "To understand why setting the swap too large is an issue, consider the following situation: you are setting your swap to 1 TB, and you have 1 TB of RAM. By doing so, you are telling the kernel that you are satisfied to have 50 percent of your malloced memory (actually 1 TB of virtual memory) backed by your hard disk instead of RAM. With this type of setup, a malicious program could render many system applications unusable by forcing swap-outs of hundreds of gigabytes of virtual memory on useful applications. This could render the system many hundreds or thousands of times slower than it would run without a swap. Even worse: a simple malloc infinite loop would need to write 1 TB to the hard disk before being killed by the out-of-memory (OOM) killer (a function or mechanism that has to terminate one or more processes in order to free up memory for the system). This would take hours—even on a fast hard disk and even with the rest of the system idle and not triggering swap-ins. Additionally, the larger the swap space, the harder it is for the virtual memory to detect that the system is out of memory." In other words, for peak performance you want your swap to be _as small as it needs to be_, but still enough to give the kernel the space it requires to page out unused portions of RAM to disk to give it more space to allocate RAM for more useful data. For small systems (4GB of RAM or less) the old formulae of Swap = 2x RAM are a fair approximation of 'small enough as it needs to be', but in an era where 8GB is normal and 64GB is not extreme, the simple fact is those old recommendations do not hold true. This is where the arbitrary "2GB is normally enough" recommendation comes from. Hibernation is the exception, as you need to have enough to store the system RAM to disk. However it's worth noting that the hibernation process will COMPRESS that RAM image, so sizing your swap to equal your RAM size is actually going to oversize the swap somewhat even for that usecase..but better safe than sorry considering the possibly variable compressability of the data in RAM. On large systems you do however then have the compromise of slowing down general memory performance when hibernation is enabled due to a large swap space which you only needed for hibernation I suppose it would be nice if we had some mechanism for hibernating to disk somewhere other than swap for that reason. Regards, -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org