Adding swap space

To support the RAM overcommitment ratio, you need to add swap space. The swap size depends on the chosen RAM overcommitment ratio and can be calculated by using the following formula:

(total RAM – RAM used for system) * (RAM overcommitment ratio – 1)

To better understand how the minimum swap size is calculated, consider the following example:

  • The total amount of physical RAM on a compute node is 24 GiB
  • 8 GiB of RAM is reserved for the system
  • The desired RAM overcommitment ratio is 1.5

According to the formula, the minimum required swap size will be 8 GiB. After calculating the required swap size, proceed to configuring swap space by creating a swap file.

Limitations

  • After the swap file is created, its size cannot be modified.

Prerequisites

  • To be able to create a swap file, the root directory must have 100 GiB of free space after the swap file creation. For example, to create a swap file of 8 GiB, ensure that at least 108 GiB is available in the root directory.

To create a swap file

On a compute node, execute the configure-swap.sh script specifying the desired swap size:

# /usr/libexec/vstorage-ui-agent/bin/configure-swap.sh -s 8192

The script creates a swap file, prepares the swap space, and adds the swap mount point to /etc/fstab.

To enable RAM overcommitment for the entire compute cluster, execute this script on each compute node.

To check that the swap file is successfully created, run:

# swapon -s
Filename               Type         Size    Used    Priority
/dev/sda3              partition    8258556    0    -2
/swapfile0             file         8389628    0    -3

To increase the swap size

Add another swap file by running:

# /usr/libexec/vstorage-ui-agent/bin/configure-swap.sh -s 8192 --append

For the entire compute cluster, execute this script on each compute node.