# How do you add swap on a VPS?

> How to add swap on a VPS in 5 commands: a 1 or 2 GB swap file, an fstab line and a lower swappiness, for small 1 GB and 3 GB plans.

- URL: https://jadekvm.com/guides/how-to-add-swap-on-a-vps/
- Last updated: 2026-11-16
- Publisher: JadeKVM (https://jadekvm.com)

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.

**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*

| Plan | RAM | Disk | Suggested swap |
| --- | --- | --- | --- |
| Bead | 1 GB | 20 GB NVMe | 1 GB |
| Pendant | 3 GB | 45 GB NVMe | 2 GB |
| Bangle | 4 GB | 80 GB NVMe | 1 to 2 GB, optional |
| Seal | 8 GB | 160 GB NVMe | Optional |
| Vessel | 16 GB | 200 GB NVMe | Rarely 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*

```bash
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](https://jadekvm.com/guides/how-to-run-a-telegram-bot-on-a-vps/ "How do you run a Telegram bot on a VPS?") or a small [Docker container](https://jadekvm.com/guides/how-to-install-docker-on-a-vps/ "How do you install Docker on a VPS?"). If you outgrow it, the [4 GB Asia VPS page](https://jadekvm.com/4gb-asia-vps/ "What does a 4 GB VPS in Asia cost with crypto?") 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

1. [Swap, Ubuntu community help wiki](https://help.ubuntu.com/community/SwapFaq) — Ubuntu (read 2026-11-16)
2. [Swap, Debian Wiki](https://wiki.debian.org/Swap) — Debian (read 2026-11-16)
3. [Documentation for /proc/sys/vm (swappiness)](https://docs.kernel.org/admin-guide/sysctl/vm.html) — 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. [Order Bead in Hong Kong](https://jadekvm.com/app/checkout/?plan=bead&term=12m&location=hk-hkg&from=how-to-add-swap-on-a-vps&lang=en) · [See every plan](https://jadekvm.com/pricing/ "How much does a JadeKVM server cost per month?")

---

JadeKVM: JadeKVM sells Linux KVM VPS in Hong Kong, Tokyo and Singapore, paid in crypto with no ID document, and publishes the measured latency from each city to the rest of Asia. 5 plans from 1 to 16 GB of RAM cost the same in all three cities and, on the 12-month term, sit at least 25% under a named comparable no-KYC crypto plan read on 16 November 2026. The operator is DomaineGoat LLC, Panama.
