swapon
Swapon is a command line tool in Unix-like operating systems that is used to enable swapping or paging space on a running system. The command is used to activate a swap area that has been previously created.
To use swapon, you need to have administrative privileges or root access. The syntax for the command is simple and follows the pattern swapon [options] device
. The "device" refers to the swap device or file to be activated.
The command can take various options, such as -p or --priority, which allows you to set the priority of the swap space in case multiple swap areas are enabled. The higher priority values will be used before the lower ones. Additionally, using the -s or --summary flag with swapon displays a summary of swap usage by device.
Swapon can also be used to add additional swap space on-demand, by specifying a new swap device or file. It can be helpful in scenarios where you have limited physical memory and need to extend the virtual memory resources available to the system.
The swapon command is often used in combination with the swappiness kernel parameter, which controls the tendency of the system to swap out the contents of memory to disk. Adjusting these settings appropriately can help optimize the system's performance and memory management.
List of commands for swapon:
-
swapon:tldr:0dcc5 swapon: Enable all swap areas.$ swapon -atry on your machineexplain this command
-
swapon:tldr:3f813 swapon: Enable swap by label of a device or file.$ swapon -L ${swap1}try on your machineexplain this command
-
swapon:tldr:5e1eb swapon: Enable a given swap partition.$ swapon ${-dev-sdb7}try on your machineexplain this command
-
swapon:tldr:b569a swapon: Get swap information.$ swapon -stry on your machineexplain this command