swapon

Activate swap space in Linux system

Supplementary instructions

swapon command is used to activate the swap space in the Linux system. The memory management of the Linux system must use the swap area to create virtual memory.

grammar

swapon(option)(parameter)

Options

-a: Start all devices set to swap in the /etc/fstab file as swap areas;
-h: display help;
-p<priority>: Specifies the priority of the swap area;
-s: Display the usage status of the swap area;
-V: Display version information.

Parameters

Swap space: Specify the swap space that needs to be activated, which can be a swap file or a swap partition. If it is a swap partition, specify the device file corresponding to the swap partition.

Example

mkswap -c /dev/hdb4 (-c is to check whether there are bad blocks)
swapon -v /dev/hdb4
swapon -s
Filename type Size Used Priority
/dev/hda5 partition 506008 96 -1
/dev/hdb4 partition 489972 0 -2