How to permanently disable swap file?

This is how to disable the swap file in Ubuntu 17.04

To turn off the swapfile. Run the following command:

sudo swapoff /swapfile         

Now disable the swap file in /etc/fstab. I'm using Vim.

sudo vim /etc/fstab

Your /etc/fstab file should have a '#' in front of '/swapfile'

enter image description here

After this is done. save your changes and exit.

Now we're going to physically remove the swap file. run the following command:

sudo rm -f /swapfile

and voila! For the changes to take full effect, reboot the system, and use the 'free' command to confirm there is no available space for swap.

Tags:

Swap

17.04