SWAP partition is not always necessary on a modern Linux PC.
SWAP partition is not always necessary on a modern Linux PC.
Swapping offers several benefits. Consider it as a layered memory system for a hard drive to an SSD—when you have data that isn’t immediately required but recreating it would be expensive, keeping it in memory is beneficial. You could also build an overlay and use mmap(), which is interesting because swapping on quicker storage like SSDs or NVMe is much more efficient than on slower drives.
For certain advanced courses it's essential even on contemporary operating systems. When producing large videos with tools like kdenlive or ffmpeg, your system might become unresponsive without sufficient swap space. Or even in virtual environments.
The system remains stable even when memory runs low. It activates the OOM killer when a program demands more memory than available, eliminating the most resource-heavy applications. In a scenario where a virtual machine uses 8GB of RAM and the OOM killer is triggered, that VM will be terminated. Without an SSD, the OOM killer offers a more effective approach overall. Relying on additional storage devices like hard drives only worsens performance as data grows.
In reality it didn't occur for me with virtual machines, although memory usage was high. Even for 4K at 120 fps with kdenlive, the OOM killer wasn't sufficient. After about 30 minutes it froze, even when using REISUB. I tried it because I had only 8 gigabytes of RAM. I retried with a swap partition, but it remained unresponsive. It was just a test since I had plenty of memory. I think it's important to set up safeguards to avoid data loss during forced shutdowns in certain scenarios.