swapon
system administrationLinux/Unix
The swapon command is one of the most frequently used commands in Linux/Unix-like operating systems. swapon Enable devices and files for swapping
Quick Reference
Command Name:
swapon
Category:
system administration
Platform:
Linux/Unix
Basic Usage:
swapon [options] [arguments]
Common Use Cases
Syntax
swapon [options] [special]
Options
Option | Description |
---|---|
-a, --all |
Enable all swap areas in /etc/fstab |
-d, --discard |
Enable swap discards for SSDs |
-e, --ifexists |
Silently skip devices that do not exist |
-f, --fixpgsz |
Reinitialize the swap space if necessary |
-o, --options OPTIONS |
Comma-separated list of swap options |
-p, --priority PRIORITY |
Specify the priority of the swap area |
-s, --summary |
Display summary about used swap devices |
--show[=COLUMNS] |
Display summary in definable table |
--output-all |
Output all available columns |
--noheadings |
Don't print headings |
--raw |
Use raw output format |
--bytes |
Print sizes in bytes |
-L, --label LABEL |
Enable swap by LABEL |
-U, --uuid UUID |
Enable swap by UUID |
-v, --verbose |
Be verbose |
-h, --help |
Display help and exit |
-V, --version |
Display version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the swapon
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
swapon /dev/sdb2