Skip to content

swapoff Command Cheat Sheet

swapoff disables devices and files for paging and swapping.


Synopsis

swapoff [options] [specialfile...]

Basic Usage

Disable a Specific Swap File

sudo swapoff /swapfile

Disable a Swap Partition

sudo swapoff /dev/sda2

Dissable All Swap (-a)

Disable all swap devices defined in /etc/fstab.

sudo swapoff -a
Commonly used before Kubernetes installation/maintenance.


Notes

  • Performance: Running swapoff forces the kernel to move valuable data from swap back into RAM. If you don't have enough RAM, the system may freeze or OOM Kill processes.