No KYC · KVM in Hong Kong, Tokyo and Singapore at one price · Pay in BTC, USDT, USDC, ETH, SOL, LTC, XMR
Language: English
Build a server

Guide · Debian 13 and Ubuntu 24.04 · checked 16 November 2026

How do you add swap on a VPS?

This is how to add swap on a VPS with a swap file, on Debian 13 or Ubuntu 24.04, so small plans survive memory spikes.

Last updated: · 4 min read

Quick answer

How do you add swap on a VPS?

To add swap on a VPS, create a file with fallocate -l 1G /swapfile, set mode 600, run mkswap and swapon, then add a line to /etc/fstab so it returns after a reboot. JadeKVM Bead, with 1 GB of RAM, gains the most from 1 GB of swap; Pendant, with 3 GB, from 2 GB.

In brief
  • A swap file needs no repartitioning and takes 5 commands.
  • Size: 1 GB on Bead, 2 GB on Pendant; larger plans rarely need it.
  • fstab line keeps it after a reboot.
  • swappiness 10 makes the kernel use swap only under pressure.

How to add swap on a VPS in 5 steps?

Run the commands with sudo. Check first that swapon --show prints nothing.

  1. Create the file

    Run sudo fallocate -l 1G /swapfile, or 2G on a 3 GB plan.

  2. Lock it down

    Run sudo chmod 600 /swapfile so no user can read memory pages.

  3. Format and enable

    Run sudo mkswap /swapfile, then sudo swapon /swapfile.

  4. Make it permanent

    Add /swapfile none swap sw 0 0 to /etc/fstab.

  5. Tune swappiness

    Set vm.swappiness=10 in /etc/sysctl.d and apply it.

How much swap should each plan get?

Suggested swap size for each JadeKVM plan, with RAM and disk from the price list
PlanRAMDiskSuggested swap
Bead1 GB20 GB NVMe1 GB
Pendant3 GB45 GB NVMe2 GB
Bangle4 GB80 GB NVMe1 to 2 GB, optional
Seal8 GB160 GB NVMeOptional
Vessel16 GB200 GB NVMeRarely needed

Why add swap on a small VPS?

Swap gives the kernel room to park idle pages, so a memory spike slows the server instead of killing a process. Without swap, the out-of-memory killer stops the largest process, often your database. A package upgrade or a Docker build can cause such a spike on 1 GB.

Swap is not extra RAM. Disk is far slower than memory, even NVMe. If the server swaps all day, it needs a larger plan, not more swap.

Create a 1 GB swap file
swapon --show
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
echo 'vm.swappiness=10' | sudo tee /etc/sysctl.d/90-swappiness.conf
sudo sysctl --system
free -h

Which swappiness is best on a VPS in 2026?

10 is a common choice for servers: swap stays idle until memory runs short. The kernel default is 60, which pushes idle pages out sooner. A lower value keeps active data in RAM. The kernel documentation explains the scale from 0 to 200.

Does swap fit the Bead and Pendant plans?

Yes: both have room on disk and gain the most from it. Bead offers 1 shared vCPU, 1 GB RAM, 20 GB NVMe, 1 TB a month. Pendant offers 1 shared vCPU, 3 GB RAM, 45 GB NVMe, 1 TB a month. According to JadeKVM's survey of 2 November 2026, comparable 1 GB plans at 12 no-KYC crypto hosts averaged $10.91 a month; Bead costs $3.75 on 12 months.

With swap, Bead can run a Telegram bot or a small Docker container. If you outgrow it, the 4 GB Asia VPS page shows the next step.

How do you check or remove swap later?

free -h and swapon --show show use; swapoff and the fstab line undo it. Run sudo swapoff /swapfile, delete the line from /etc/fstab, then remove the file. Watch vmstat 5 for the si and so columns: steady numbers above zero mean the plan is too small.

Can swap break anything on a KVM server?

No, on KVM the swap file is yours like any other file. JadeKVM servers run their own kernel, so swap behaves as on a physical machine. vCPU cores are shared with other servers on the same physical machine; RAM and NVMe space are reserved for each server. Keep at least a few GB of disk free after creating the file.

Questions about swap on a VPS

How much swap does a 1 GB VPS need?

1 GB is a good start. It absorbs spikes during upgrades or builds without filling a 20 GB disk.

Is a swap file as good as a swap partition?

On current kernels, yes. A file is easier to resize and needs no repartitioning.

Does swap wear out NVMe disks?

Light swap use is harmless. Heavy, constant swapping means the server needs more RAM.

Can I add swap on Ubuntu 24.04 without a reboot?

Yes. swapon enables it at once; the fstab line only matters for the next boot.

Which is better on a small VPS: swap or zram?

zram compresses pages in RAM and is fast, but uses CPU. A swap file is simpler and fine for occasional spikes.

Verdict
  • A 1 GB swap file on Bead and 2 GB on Pendant, with swappiness 10, prevents most out-of-memory kills.
  • Constant swapping is a sign to move up a plan, not to add more swap.
Sources (3)
  1. Swap, Ubuntu community help wiki — Ubuntu (read 2026-11-16)
  2. Swap, Debian Wiki — Debian (read 2026-11-16)
  3. Documentation for /proc/sys/vm (swappiness) — kernel.org (read 2026-11-16)

Start small and add swap

Bead offers 1 vCPU / 1 GB / 20 GB for $3.75 a month on 12 months.

From $3.75/mo on 12 months · HK · TYO · SIN

Build