Linux & Swap: Needed or not?

Hi All

Over the years I’ve listened to many discussions in the Linux arena about swap - needed or not - and about what is better: a swap file or a swap partition…

In my own experience, any linux (UN*X) server runs better WITH swap. Even if your server has a terabyte of RAM and probably will never use swap, it’s still better with.

The shown screenshot shows a Proxmox 8.22 server, with 156 GB RAM, and has never, so far, used more than 100 GB RAM. I do have long time stats on zabbix about RAM / CPU usage…
The server itself is now about 4 years old.

The current screenshot shows an abnormal high swap usage, this was due to the fact of our UPS battery being dead on 30. April, due to non-replacement of battery packs…

Yet this server has always used some amount of swap, even with over 50 GB free RAM!

So my answer is: Yes, even Linux is better off with Swap!

A Swap partition is better than a swap file, as it’s there even if a file system error renders the swap file unuasble.
And: a swap partition can be discovered and used by “Linux Live / Rescue CDs / USB Sticks” :slight_smile:

My 2 cents


I totally agree with you: always add some SWAP, it may save your ass when things go wrong!

1 Like


Thanks for again confirming the fact that NethServer has VERY good, sensible Devs!

I’ve always trusted the NethServer devs (Expressed this often in regard to NS8!), and this just confirms that again!

Kudos to the whole dev team, for the incredible work done with NS8 & NethSecurity, despite of the unneeded additional preasure due to Centos7 EOL. You guys are amazing!

My 2 cents


Yeah but… all the swap in the world won’t help you if you spin up a vm with a greater memory allocation that your host has available… ask me how I know. :rofl:

1 Like

Some Linux or BSD will even then boot. But the moment you give any load,
it will trash your IO and CPU, but it’s not a bug, it’s a feature!
It’s called “reality check”!!!


In the 90ies, with talk about extended RAM, virtual RAM, soft RAM some smart guy said:

“There’s only one replacement for RAM, and that’s plenty more real RAM!”

→ He was right!

And yes, the world does need more than 640 KB of it!

My 2 cents

the first things I do on server/laptop is yes to create a partition of swap but nowadays we got a lot of RAM so writing to the disk is useless and really slow for the machine

I set a swappiness to 10% or 15% to start to swap files if the RAM usage is going to this values

root@promox:~# cat /etc/sysctl.d/99-swappiness.conf

root@promox:~# free -h 
               total        used        free      shared  buff/cache   available
Mem:            62Gi        18Gi        41Gi        40Mi       2.9Gi        43Gi
Swap:          7.4Gi          0B       7.4Gi

I still believe you need a bit of SWAP partition, you never know why and when but one day you will be happy to get it


You’ve seen recently phones adding virtual ‘RAM’ is that a form of swapt? Cause surely RAM is ram and storage storage

I agree, I always create a swap partition, but now I need to know how a UPS battery eats up swap space?

I’m guessing that if the server is connect to the UPS for monitoring purposes, if the battery picks up the load due to a power failure, the UPS monitoring software may force the system to use more swap than memory as a fail safe to help reduce data loss should the UPS battery die before the power comes back on?

Hi @Linux_monger , @bwdjames

I do not know, but I do know that Proxmox is capable of caching the NFS access for Shared Storage for the time eg a Synoology NAS takes to reboot due to upgrades. This has never been an issue. Bus a UPS Outage means also the NAS is down…

Do not really know, just had to “fix” it!


My 2 cents

I deal with Linux Swap issues on a regular basis, so I have an answer for why swap is being used in a specific context.

The linux kernel has a fairly aggressive algorithm to shift idle memory pages to swap. It does this so that available physical memory can be used for features that improve performance, such as buffers and cache. If the immediately available free memory is not sufficient to fulfill a memory allocation request, then the caches and buffers can be flushed to meet the requirement. The relevant statistic from /proc/meminfo is MemAvailable, which represents the available memory for allocation if all the caches and buffers were released.

So memory pages in swap are those that have not been accessed for some time - code that is only used during startup, or by features of an application that are not being used. It is not an indication of memory pressure, and isn’t generally a bad thing.

Swapping (memory rapidly moving from swap to physical and vice versa) is a problem, but that is a very different situation.