Formula for calculating the swap partition size during the installation of Red Hat Enterprise Linux

When performing the installation of Red Hat Enterprise Linux or Fedora, you can accept the default size of the swap partition or enter the optimal size manually. Here is the formula to calculate the swap partition size.

If total memory (RAM) < 2 GB swap size = total memory x 2 Else if total memory > 2 GB

swap size = total memory + 2 GB

According to Red Hat the swap file should never be less than 32 MB. The size also depends on the application, it is normally a good idea to check with the application vendor for recommended swap size.