To Swap or Not To Swap | TrueNAS Tech Talk (T3) E009

Back for 2025, TrueNAS Tech Talk opens the year with a discussion about swap usage on TrueNAS (and why it isn’t a default anymore) as well as a quick update on the 24.10.1 release adoption.

Submit questions and inquiries to t3@truenas.com and don’t forget to visit our other YouTube channels at ‪‪@TrueNAS‬ and ‪@iXsystemsInc‬

2 Likes

The most compelling argument you made was that users of your systems often use bad hardware, usb sticks, etc and were swapping out to super slow devices. That actually makes sense, coming from this always use swap server guy. I reject the argument that a properly configured swap (including swappiness, vfs_cache_pressure, right device, etc) is bad though, done thousands of systems with swap and not encountered issues. It has it’s advantages on server hardware even in 2024 and the OS distributions still recommend swap in most cases, I would say they have their reasons. That being said, a NAS workload which also does apps, vms, etc. and run by non admin folks is not the same as many other workloads. So, I see the point here esp. with underpowered systems being overused and you guys having to debug issues. Good video. Decent argument.

1 Like

I made a similar argument in the related thread.

I don’t see a reason to outright disable swap.

If the boot device is an SSD, and has plenty of unused space, what is the harm of a 2-GiB swap file/partition, which can serve as a cushion to prevent OOM or system crashes for rare situations?

If SCALE truly does “behave properly” in regards to memory/ARC, and will not swap anything to disk during normal operation, then a small swap partition will remain essentially untouched, except for those rare cases where it could prevent a catastrophic failure.

Why not then make swap optional? Have it disabled by default, and provide a simple toggle in the GUI. The harmless 2-GiB partition/file on the boot device won’t interfere with anything.


My TrueNAS Core system (previously FreeNAS), has always had an active swap partition. Not once did it ever swap to disk. But it’s always there “just in case” the system is pushed to its limits. Even with the presence of a 16-GiB swap partition on the boot device, it never swaps even kilobytes to disk.

So if Core (FreeBSD) can act graceful with the presence of active swap, why not SCALE? Ideally, if SCALE has a small 2-GiB swap file/partition on the boot device, you would expect it to never be touched, since it supposedly has proper memory management, like its FreeBSD cousin.

My concern is that Linux’s memory management with ZFS/ARC is still inferior to FreeBSD’s, and that the presence of any active swap simply exposes it. (Otherwise, why does it even want to swap if there is plenty of available memory, and it supposedly can dynamically and safely shrink the ARC during times of high pressure?)

1 Like