Introduction
On a cPanel server, we have a script that can be used to add a swap partition/mount.
Procedure
The following script can be used:
/usr/local/cpanel/bin/create-swap
and the script helper output can be reviewed on how to use the script with:
/usr/local/cpanel/bin/create-swap --help
create-swap [--if-needed] [--size SIZE] [-v | --verbose]
Creates a swap file of size SIZE, which is a number followed by M (for MiB) or G
(for GiB). If omitted, defaults to 1G.
If --if-needed is specified, perform the action only if the system is low on
memory and has no existing swap.