How to disable swap on Ubuntu 21.04

How to check swap utilization ?

Use free -h command

sandeepsr@master:~$ free -h
               total        used        free      shared  buff/cache   available
 Mem:          1.9Gi       222Mi       149Mi       1.0Mi       1.6Gi       1.5Gi
 Swap:         1.7Gi          0B       1.7Gi

How to disable Swap ?

Use swapoff -a command

sandeepsr@master:~$ sudo swapoff -a

sandeepsr@master:~$ free -h
               total        used        free      shared  buff/cache   available
 Mem:          1.9Gi       221Mi       150Mi       1.0Mi       1.6Gi       1.5Gi
 Swap:            0B          0B          0B

How to enable swap?

Use swapon -a command

sandeepsr@master:~$ sudo swapon -a

sandeepsr@master:~$ free -h
               total        used        free      shared  buff/cache   available
 Mem:          1.9Gi       221Mi       150Mi       1.0Mi       1.6Gi       1.5Gi
 Swap:         1.7Gi          0B       1.7Gi

Leave a Comment

Your email address will not be published.

Scroll to Top