How to Enable Swap Memory
If you're running WuWei on a VPS with limited RAM (e.g. 2GB or less), enabling Swap Memory can significantly improve stability and performance, especially during high-load tasks like video transcoding or Docker builds.
Note: Swap helps with memory overflow but is not a replacement for RAM. For better performance, consider upgrading your server if possible.
Steps to Enable Swap on Debian
1. Check if Swap Is Already Enabled
swapon --show
If nothing is returned, swap is not active.
2. Create a Swap File
fallocate -l 2G /swapfile
Replace 2G
with your desired swap size. A common rule of thumb is:
Swap Size = RAM × 2 (e.g. for 2GB RAM, use a 4GB swap file).
If fallocate
is not available or fails, use:
dd if=/dev/zero of=/swapfile bs=1M count=2048
3. Set Correct Permissions
chmod 600 /swapfile
4. Format the File as Swap
mkswap /swapfile
5. Enable the Swap File
swapon /swapfile
6. Make It Persistent Across Reboots
Add the following line to your /etc/fstab
file:
/swapfile none swap sw 0 0
Confirm Swap is Active
free -h
You should now see swap memory listed under the Swap row.