Back to the command reference

swapon

DisksAdvanced In real Linux

Enable swap space

Name: swapon = swap on

This command needs a real Linux system; you can practise it in real Linux mode.

Full man page

Description

swapon enables a swap partition or file. When RAM runs short, the kernel moves idle memory pages there. swapon --show lists active swap.

Syntax

swapon [OPTION]... [DEVICE]

Common options

--showShow active swap
-a / --allEnable every swap area in /etc/fstab
-p / --priority PRIOPriority (higher numbers are used first)

Examples

  • $ swapon --show

    Show swap

    Explain
  • $ sudo mkswap /dev/sda2 && sudo swapon /dev/sda2

    Make the practice disk’s second partition swap and turn it on

    Explain

Related