Victus Cloud / Support
VPS

Add a swap file

Add a swap file to your Victus VPS to survive memory spikes and avoid the OOM killer when RAM is tight.

Swap is disk space the kernel uses as overflow when RAM fills up. On a smaller VPS plan a swap file is a cheap safety valve: it keeps the out-of-memory (OOM) killer from abruptly terminating your app during a brief memory spike. This is a file-based swap, so no repartitioning is required.

Swap is a cushion, not a substitute for RAM

Disk is far slower than RAM, so a machine that swaps heavily and constantly will feel sluggish. Use swap to absorb spikes; if you swap all the time, upgrade the plan for more RAM.

Create a swap file

# Create a 2G swap file (adjust size as needed)
fallocate -l 2G /swapfile
# If fallocate is unavailable:
# dd if=/dev/zero of=/swapfile bs=1M count=2048

# Lock down permissions (required)
chmod 600 /swapfile

# Format and enable it
mkswap /swapfile
swapon /swapfile

# Confirm it is active
swapon --show
free -h

Make it survive reboots

# Add to fstab so it re-enables on boot
echo '/swapfile none swap sw 0 0' >> /etc/fstab
Do not add a duplicate fstab line

Only append the swap line once. If you run the setup twice, check /etc/fstab and remove any duplicate /swapfile entry, or boot will error.

Tune how eagerly it swaps

# Lower swappiness = prefer RAM, only swap when really needed (good for servers)
sysctl vm.swappiness=10

# Persist it
echo 'vm.swappiness=10' >> /etc/sysctl.d/99-swappiness.conf
Sizing rule of thumb

For servers, 1x to 2x your RAM is a reasonable swap size (e.g. 2-4G on a 2G VPS). Make sure you have the free disk space first with df -h — and remember swap consumes disk that counts toward your plan.

Was this article helpful?

Still stuck?

Our team can help with your account or service.

Open a ticket →