How to disable swap permanently in ubuntu?

by aliya.yundt , in category: General Help , 2 years ago

How to disable swap permanently in ubuntu?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by sarai_bergstrom , 2 years 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.

by monroe.bahringer , 3 months ago

@aliya.yundt 

To disable swap permanently in Ubuntu, you can use the following steps:

  1. Firstly, to turn off swap temporarily, you can run the following command:
1
sudo swapoff -a


  1. Next, you need to open the /etc/fstab file in a text editor with administrative privileges. You can do this with the following command:
1
sudo nano /etc/fstab


  1. In the /etc/fstab file, you will see a line that represents the swap partition. It will look something like this:
1
UUID=<swap-partition-uuid> none            swap    sw              0       0


To disable the swap partition, you can comment out this line by adding a # at the beginning, making it like this:

1
#UUID=<swap-partition-uuid> none            swap    sw              0       0


  1. Save the changes to the /etc/fstab file by pressing Ctrl + X, then Y for Yes, and then Enter.
  2. Finally, you need to reboot your system for the changes to take effect. You can do this by running:
1
sudo reboot


After following these steps, the swap partition should be disabled permanently on your Ubuntu system. It's worth noting that disabling swap can impact system performance, so make sure to consider the implications before doing so.