remove swap file ubuntu code example

Example 1: ubuntu turn off swap

sudo swapoff -a && sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

Example 2: create swapfile ubuntu

sudo swapon --show

Example 3: disable swap ubuntu 18.04

check swap: free -m
off swap: sudo swapoff -v /swapfile
comment swap entry from: /etc/fstab
remove swap file: sudo rm /swapfile
----------------------------------------------------------------
Identify configured swap devices and files with cat /proc/swaps.
Turn off all swap devices and files with swapoff -a.
Remove any matching reference found in /etc/fstab.
Optional: Destroy any swap devices or files found in step 1 to prevent their reuse. Due to your concerns about leaking sensitive information, you may wish to consider performing some sort of secure wipe.

Example 4: create swapfile ubuntu

/swapfile swap swap defaults 0 0

Example 5: create swapfile ubuntu

sudo swapon /swapfile

Example 6: create swapfile ubuntu

sudo nano /etc/fstab