Linux VPS SWAP: Setup and Optimization

VDS / VPS Servers · 19.02.2025
Linux VPS SWAP: Setup and Optimization

Create Swap File

fallocate -l 2G /swapfile
chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab
sysctl vm.swappiness=10
⚠️ Active swap on HDD severely degrades performance. On SSD it's acceptable but indicates RAM shortage.
← Back to Knowledge Base Ask Support