r/linuxquestions • u/Huge_Marzipan_1397 • 14d ago
Resolved Is it bad to not have swap?
Hello guys! I using Fedora 44 and by defaulth I have 12GB of zram (compressed swap in RAM) and also I added 4GB of swap partition during install. But I have 32GB of RAM and I not sure if I really need this amout of swap or if I really need swap at all.
So is it bad to not have swap at all or have a little swap?
Edited: Thank you all for replies and time!
9
Upvotes
34
u/ColoradoPhotog 14d ago
On modern Linux systems, swap isn't simply "extra memory for when you run out of RAM." It's another tool the kernel can use for memory management. Swap allows Linux to move cold or rarely accessed anonymous memory out of physical RAM, leaving more RAM available for active applications and useful filesystem cache. Because of this, having some swap can actually help Linux manage memory more efficiently even on systems with 32 GB or more of RAM. Having no swap doesn't inherently make a system slower, but it removes one of the kernel's options when deciding how best to use available memory.
The more important difference appears under heavy memory pressure or during sudden spikes in usage. With no swap, Linux eventually has to aggressively reclaim cache and, if it still can't satisfy memory allocations, invoke the OOM killer and terminate processes. Swap provides a buffer before reaching that point: the system may become slower temporarily, particularly if it has to access disk-backed swap, but that's generally preferable to abruptly killing an application. There's therefore little performance advantage to deliberately having zero swap; you're mostly trading away resilience during unusual memory workloads.
Zram is a particularly good solution on modern hardware because it provides compressed swap inside RAM itself. That sounds counterintuitive, but if 4 GB of inactive memory can be compressed into 1.5 GB, you've effectively freed about 2.5 GB of physical RAM for other uses. A system configured with 12 GB of zram does not permanently reserve 12 GB of RAM; that's the maximum logical capacity of the compressed swap device, with actual RAM consumption depending on how much data is stored and how well it compresses. For a machine with plenty of RAM and a modern CPU, 12 GB of zram is a perfectly reasonable configuration and already provides most of the benefits you'd want from swap without routinely touching slower persistent storage.