swapoff
Deactivate swap space
TLDR
Disable a given swap area
Disable all swap areas in /proc/swaps
Disable a swap partition by its label
SYNOPSIS
swapoff [options] [device...]
PARAMETERS
-a, --all
Deactivates all swap areas listed in /etc/fstab.
-h, --help
Displays help information and exits.
-v, --verbose
Enables verbose output, showing more details about the operation.
-V, --version
Displays version information and exits.
DESCRIPTION
The swapoff command is used to deactivate swap areas (partitions or files) on a Linux system. When swap is active, the kernel can move less-used pages of memory from RAM to the swap space on disk, freeing up physical memory for more active processes. Using swapoff reverses this process; it attempts to move all data from the specified swap area back into physical RAM and then marks the swap area as inactive. This can be necessary before modifying a swap partition, removing a swap file, or when troubleshooting memory issues. Running swapoff on a busy swap area can significantly impact system performance and may even lead to out-of-memory (OOM) conditions if there isn't enough physical RAM to hold all the data currently in swap. It requires root privileges to execute.
CAVEATS
swapoff requires root privileges.
Deactivating swap can lead to out-of-memory (OOM) errors and system instability if insufficient physical RAM is available to hold the data currently stored in swap. It may also temporarily degrade system performance as data is moved from disk back into RAM.
USAGE EXAMPLES
To deactivate a specific swap partition: swapoff /dev/sdb2
To deactivate a specific swap file: swapoff /mnt/swapfile.img
To deactivate all active swap areas: swapoff --all
EXIT STATUS
Returns 0 on success, or a non-zero value on failure.