Guide
Add swap to a VPS in one command (beta)
Last updated: 1 December 2026
This free script adds a swap file (2 GB by default) to a server that has none. It is new (beta): read it first.
Instant VPS from $7.99 a month
- Sign up with an email address, a password and any nickname: no ID, no phone number.
- Pay with Monero, Bitcoin, Litecoin, USDT, USDC, SOL or TRX, or by card through MoonPay. Monero is the most private way to pay; USDT or USDC on Solana confirm in seconds, and we add no transfer fee on them.
- Orders are processed automatically and delivered in about 10 minutes.
- New VPS orders have a 24-hour guarantee (see the terms for what is covered).
See Instant VPS plansHow ordering worksRequirements and run
Ubuntu 22.04/24.04 or Debian 12/13 with root access, at any provider. Download, compare the SHA-256 (27517792f3615458eb96901bc29e5ca0d04e570518c19c84db1bdfbe9ebc60fb), read it, then run:
wget https://phantomvps.com/blog/swap.sh
sha256sum swap.sh
less swap.sh
sudo bash swap.sh
What it changes
- Creates /swapfile and activates it
- Adds one line to /etc/fstab so it returns after a reboot
- Sets swappiness to 10
Good to know
- Choose the size with SIZE_GB (1 to 32)
- Swap helps with short memory peaks; it does not replace RAM
- It stops if swap already exists or disk space is low
Questions and answers
How much swap do I need?
On a small server, 1 to 4 GB is a common choice.
How do I remove it?
Run swapoff /swapfile, delete the file and its line in /etc/fstab.
Is it tested?
It is a beta. Please report problems to support@phantomvps.com.
Does it work on other providers?
Yes, on any server with a supported system and root access.
Ready to try it? Instant VPS from $7.99 a month
- Pick a plan: Instant 1-2, $7.99 a month or all Instant VPS plans.
- Sign up with an email address, a password and any nickname: no ID, no phone number.
- Pay with Monero, Bitcoin, Litecoin, USDT, USDC, SOL or TRX, or by card through MoonPay. Monero is the most private way to pay; USDT or USDC on Solana confirm in seconds, and we add no transfer fee on them.
- Orders are processed automatically and delivered in about 10 minutes.
- New VPS orders have a 24-hour guarantee (see the terms for what is covered).
- Before you pay you can ping our test IPs and read the live status page.
- Support is available 24/7 via email and our client ticket portal.
See Instant VPS plansHow ordering works