← 返回命令列表

Linux command

swapon 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Example

swapon

Enable

sudo swapon /path/to/swapfile

Example

sudo swapon -a

Example

sudo swapon -L swap_label

Example

sudo swapon -U uuid

Example

swapon -s

说明

swapon enables devices and files for paging and swapping. Swap space can be specified by device path, label (-L), or UUID (-U). The command is typically invoked during system startup to distribute paging activity across multiple storage resources.

参数

-a, --all
Enable all swap devices marked in /etc/fstab
-d, --discard=policy
Enable trim/discard operations; policy can be 'once' or 'pages'
-e, --ifexists
Silently skip devices that do not exist
-f, --fixpgsz
Reinitialize swap space if page size mismatches kernel
-L label
Use swap partition with the specified label
-U uuid
Use swap partition with the specified UUID
-p, --priority priority
Set swap priority (-1 to 32767, higher is preferred)
-s, --summary
Display swap usage summary (deprecated, use --show)
--show=column...
Display customizable swap area table
-T, --fstab path
Use alternative fstab file
-v, --verbose
Enable verbose output

FAQ

What is the swapon command used for?

swapon enables devices and files for paging and swapping. Swap space can be specified by device path, label (-L), or UUID (-U). The command is typically invoked during system startup to distribute paging activity across multiple storage resources.

How do I run a basic swapon example?

Run `swapon` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -a, --all do in swapon?

Enable all swap devices marked in /etc/fstab