BLOG POSTS
    MangoHost Blog / Enough RAM: Disabling SWAP in Ubuntu/Debian and CentOS/RedHat
Enough RAM: Disabling SWAP in Ubuntu/Debian and CentOS/RedHat

Enough RAM: Disabling SWAP in Ubuntu/Debian and CentOS/RedHat

Disabling swap on Linux systems, including CentOS and Ubuntu, can be done using a few simple commands. Here are the steps for both operating systems:

For CentOS and Other RHEL-based Distributions:

Turn Off All Swap Spaces:

sudo swapoff -a

This command disables all active swap spaces immediately.

Permanently Disable Swap:

To prevent swap from being enabled on boot, you need to edit the /etc/fstab file.
Open /etc/fstab in a text editor with superuser privileges, for example:

sudo nano /etc/fstab

Comment out or delete the lines referring to swap partitions or files (usually labeled as swap in the file).
Save and close the file.

Reboot (Optional):

Reboot your system to ensure that the changes are correctly applied and that no swap is active:

sudo reboot

For Ubuntu and Other Debian-based Distributions:

Turn Off All Swap Spaces:

sudo swapoff -a

This command disables all active swap spaces immediately.

Permanently Disable Swap:

To permanently disable swap, edit the /etc/fstab file.

Open /etc/fstab in a text editor with superuser privileges, for example:

sudo nano /etc/fstab

Comment out or delete the lines referring to swap partitions or files. Save and close the file.

Reboot (Optional):

Consider rebooting your system to ensure that no swap is active:

sudo reboot

Important Considerations:

⚠️ Disabling swap can affect system performance, especially on systems with limited RAM.
⚠️ Ensure you have enough physical memory available to handle the system’s needs without swap.
⚠️ Disabling swap is generally not recommended on systems with limited physical memory.
⚠️ Always backup configuration files before editing.



This article incorporates information and material from various online sources. We acknowledge and appreciate the work of all original authors, publishers, and websites. While every effort has been made to appropriately credit the source material, any unintentional oversight or omission does not constitute a copyright infringement. All trademarks, logos, and images mentioned are the property of their respective owners. If you believe that any content used in this article infringes upon your copyright, please contact us immediately for review and prompt action.

This article is intended for informational and educational purposes only and does not infringe on the rights of the copyright owners. If any copyrighted material has been used without proper credit or in violation of copyright laws, it is unintentional and we will rectify it promptly upon notification. Please note that the republishing, redistribution, or reproduction of part or all of the contents in any form is prohibited without express written permission from the author and website owner. For permissions or further inquiries, please contact us.

Leave a reply

Your email address will not be published. Required fields are marked