Check the current state
First, see whether swap already exists and how much free memory there is:free -h shows the Mem (RAM) and Swap lines. If swapon --show outputs nothing, there’s no swap.
Create a swap file
Connect to the server over SSH asroot (the IP and password are in the server card in the bot) and run the commands step by step.
Create a file of the size you need
The quick way is If
fallocate:fallocate isn’t available or the file system doesn’t support it, use dd:count=2048 with bs=1M gives exactly 2 GB.Lock out access for others
The swap file must be accessible to root only, otherwise the system will refuse to enable it:
How much to allocate
There’s no hard rule; here’s a rough guide:| Server RAM | Recommended swap |
|---|---|
| 1–2 GB | equal to RAM (1–2 GB) |
| 4–8 GB | 2–4 GB |
| 16 GB and up | 2–4 GB is enough |
Tune swappiness
vm.swappiness (0–100) determines how eagerly the kernel reaches for swap. The default is usually 60. For a server, it makes sense to lower it to 10 — then swap is used only when memory really runs short, not “just in case”.
Current value:
/etc/sysctl.conf:
Lumi’s disks are on NVMe, so swap here is noticeably faster than on regular HDD/SATA-SSD. But even fast NVMe is still slower than RAM. If you’re constantly hitting the memory ceiling and swap is “on fire”, that’s not a reason to inflate the file — it’s a reason to upgrade your plan through support.
Where to next
Run an LLM on the server
Ollama and local language models on a VPS.
VPS not working
Connection issues, load, and other common situations.