Depends on the workload, but the general answer is 4.1GB for a desktop and 500MB for a non-GUI server that has RAM installed for the workload.
OTOH, if you are running a VPS business and want to encourage all your cheap clients to upgrade to a better plan with a dedicated system, then install 8GB of RAM and use 200GB of swap and allow 200+ websites/clients on the single system.
Laptops shouldn't hibernate. It is a security thing. If you allow it to be in standby mode, that's fine, but never relocate between buildings any laptop while in standby or hibernated. It is a security thing. Whenever relocating the laptop, it needs to be shutdown, completely. It should go without any need to state, but laptops all need full drive encryption.
I don't like swapfiles and only use swap partitions.
About 2-3 yrs ago, there was a long thread in these forums about swap, purpose, and sizing. It is worth reading to get lots of data and opinions.
If you insist on using hibernation, then you are forced to have slightly more swap than RAM. Eeeew. I feel dirty just writing that line.
FWIW, I had a system with 16GB of RAM. I turned down the swap use and was hitting 15GB based on the workload at the time. It had 4.1GB of swap, so the system wasn't going to crash when just a little more RAM was needed.
IMHO, the point of swap is to allow the users to "feel" that RAM is running out by the system becoming slower. Really fast storage can make this harder to realize and total memory exhaustion can happen, leading to a system crash. In Linux, RAM allocations are never validated for performance reasons. This means that programs are free to allocate and allocate and allocate RAM well beyond what the system has and not be notified about any constraints. I use Firejail to add RAM constraints to hog processes like Firefox and other modern browsers. If you look at the requested memory for those programs, I've seen 69GB requested on a system with 16GB of RAM and 4G of swap. In the end, to prevent this from happening, I set a RAM constraint of 4G for Firefox and it would crash after a day or two. I moved it to 8G and it would crash after a week. Moved it to 9GB and it has been stable for years now. How's that for bloat?
One system:
Code:
$ free -hm
total used free shared buff/cache available
Mem: 30Gi 19Gi 630Mi 101Mi 10Gi 10Gi
Swap: 4.1Gi 2.1Gi 2.0Gi
Another system:
Code:
$ free -hm
total used free shared buff/cache available
Mem: 30Gi 4.7Gi 22Gi 107Mi 3.0Gi 25Gi
Swap: 4.1Gi 1.0Gi 3.1Gi
You can see that one system uses much more RAM than the other. I sized each so that either one would be able to handle all the workload on all the systems here.
For systems with limited RAM, the rules are different, but for 2GB, 4GB, 8GB RAM systems, 4GB of swap seems to be required if you use modern browsers. Less than 4GB swap and those low-RAM systems lock up far to frequently.
IMHO.
Bookmarks