Commonly Used Commands

1. Using the –help option

The –help option in the swapon command is a valuable resource for users as it offers a comprehensive and detailed list of all available options, flags, and features.

Complete set of options and flags provided by the swapon command

2. Getting the summary of all swap partitions

The purpose of this command is to provide a summary of utilized swap devices.

$ swapon -s # or --summary

Command to show the summary of all swap partitions

3. Activating a single swap area

When you supply a path to the swapon command, it activates a single swap area instead of enabling all swap areas simultaneously.

$ swapon <path to swap area>

Activating a single swap space

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.

  1. -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.
  2. -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.

Similar Reads

Options available in `swapon` command in Linux

...

Examples

1. `-a`, `-all` option in swapon...

Commonly Used Commands

1. Using the –help option...

Troubleshooting

The swap area is present in the system but remains inactive...

Conclusion

In this article, we’ve delved into the swapon command and its practical applications. Swapon serves as a robust tool for managing swap spaces in various Linux distributions. It typically comes pre-installed in the majority of distributions, leaving minimal room for oversight by maintainers. Additionally, I’ve addressed two prevalent troubleshooting issues related to swap spaces: adding a swap entry to the /etc/fstab file and modifying the ownership of a swap area....

Contact Us