On a cPanel server, we have a script that can be used to add a swap partition/mount.
The following script can be used:
and the script helper output can be reviewed on how to use the script with:
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.