What Does Swapoff Do in Linux?

What Does Swapoff Do in Linux?
Contents

swapoff disables swapping on the specified devices and files. When the -a flag is given, swapping is disabled on all known swap devices and files (as found in /proc/swaps or /etc/fstab).

Is Swapoff safe?

If there is not enough physical memory, swapoff will not succeed and issue a swapoff failed: Cannot allocate memory error. So also there, thanks to system design, it remains safe. However, again: it is not recommended to proceed this way: it will not provide any performance gains.

What is swap priority?

Swap pages are allocated from areas in priority order, highest priority first. For areas with different priorities, a higher-priority area is exhausted before using a lower-priority area.

James H. Sterling
Author

James H. Sterling

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.