Disable swap on my Gen 4 VPS & Dedicated Server
Swap on a server provides additional virtual memory when physical RAM is exhausted, and can be a great troubleshooting tool to temporarily prevent errors or crashing due to memory limitations. However, due to the potential for performance degradation, we highly recommend turning swap off after you’ve optimized your site and server processes.
Warning: This article covers an advanced technical topic. If the steps are completed incorrectly, it's possible to make unwanted changes to your site. Therefore, we strongly recommend creating a backup before you proceed. Please review the full Statement of Support to learn more about available support for additional products and services.
- Connect to your server using SSH.
- Switch to the root user.
- Deactivate swap:
sudo swapoff -v /swapfile
- Using your preferred text editor command, open your
/etc/fstab
file and remove the following line of code:
/swapfile swap swap defaults 0 0
- Delete the swap file:
sudo rm /swapfile