How to disable swap permanently in ubuntu?

by aliya.yundt , in category: General Help , a year ago

How to disable swap permanently in ubuntu?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by sarai_bergstrom , 9 months ago

@aliya.yundt 

To disable swap permanently in Ubuntu, you need to follow these steps:

  1. Open a terminal and run the command sudo swapoff -a to disable swap temporarily.
  2. Open the /etc/fstab file in a text editor with administrative privileges by running the command sudo nano /etc/fstab.
  3. Locate the line that contains the swap partition and comment it out by adding a # character at the beginning of the line. This will prevent the system from trying to mount the swap partition at boot.
  4. Save the file and exit the text editor.
  5. Reboot your system to apply the changes.


Note: Disabling swap permanently is not recommended unless you have a good reason to do so, as it can have negative effects on system performance. It is generally better to simply reduce the size of the swap partition instead.