Options available in `swapon` command in Linux
Option |
Description |
---|---|
-a, –all |
Enable all swap devices listed in /etc/fstab. |
-d, –discard |
Enable the discard option for swap devices. |
-p, –priority |
Set the priority of the swap device. |
-s, –show |
Display swap usage summary. |
-v, –verbose |
Display verbose information during execution. |
Swapon Command in Linux
The Linux swapon command serves the purpose of activating a swap partition in Linux systems. A swap partition is essentially a dedicated space used when the system’s RAM (Random Access Memory) becomes fully utilized.
It temporarily holds data that can be retrieved when required, making it particularly beneficial for systems with limited RAM capacity.
Swap space can take the form of either a device or a file. Typically, a device refers to a partition in most distributions, whereas a swapfile is a distinctive type of file located within the root directory (/). The swap partition or the swapfile is known as the specialfile which gives you two choices to activate it.
- -L Label: You can use this option to specify the device or file by its label, which is a human-readable name assigned to the device or file.
- -U uuid: You can use this option to indicate the device or file by its Universally Unique Identifier (UUID). A UUID is a unique and standardized identifier assigned to the device or file, providing a highly precise way of specifying it.
Note: You can utilize swapoff as an alternative to swapon for disabling a swap partition or swapfile. swapoff follows the same set of parameters as swapon.