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.
- 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/fstabfile and remove the following line of code:
/swapfile swap swap defaults 0 0
- Delete the swap file:
sudo rm /swapfile