Swapfile in virtual deployment

Hello fellow vyosers,

tried to use swap in VyOS installed on VPS, getting this:

$ sudo swapon /swapfile 
swapon: /swapfile: swapon failed: Function not implemented

Kernel build params:

$ zgrep -i swap /proc/config.gz 
CONFIG_ARCH_USE_BUILTIN_BSWAP=y
# CONFIG_SWAP is not set
CONFIG_ARCH_WANTS_THP_SWAP=y

Am I getting this right that there’s now way to use swapfile in VyOS (Version: VyOS 2025.04.25-0019-rolling)?

TIA, regards,
Konstantin

I would suggest if your router needs a swap file you need to give it more memory.

What’s the use case for a router with swap?

That’s an obvious solution but I wanted to know how far can I go with 1 gig of RAM on a cheap usage-based hosting :slight_smile:

As far as I understand modern Linux Kernel will always find smth to swap out to use actual RAM for caches, but it looks like the only way to check this on VyOS is to build my own image.

I could argue whats the use case for a router with containersupport? :wink:

As a pure router you shouldnt have any swap whatsoever.

However as soon as you can add containers the VyOS installation will be handy to act as a server (compared to setting it up from scratch using Debian or such) and then having swap can be a good thing.

Preferly with some sane defaults added such as:

vm.swappiness=1
vm.vfs_cache_pressure=50
2 Likes