Jetzt einen VPS bestellen!

InfrawireInfrawire LogoDokumentation
Appeler

Swap auf Linux-VPS einrichten

Swap schützt Ihren VPS bei wenig RAM.

📋 Voraussetzungen

  • Linux VPS with root/sudo
  • Free disk space (e.g. 2 GB for a 2 GB swap file)

Check RAM and current swap

Bash
free -h swapon --show

Create a 2 GB swap file

Bash
sudo fallocate -l 2G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile

Enable on boot

Bash
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Tune swappiness (optional)

10–30 is often better for VPS:

Bash
echo 'vm.swappiness=20' | sudo tee /etc/sysctl.d/99-swappiness.conf sudo sysctl -p /etc/sysctl.d/99-swappiness.conf

Stabiler Server! 🚀