Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory.
Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
According to RedHat, the size of swap space can be calculated by using the following formulae.
M = Amount of RAM in GB, and S = Amount of swap in GB, then
If M < 2
S = M *2
S = M + 2
Using this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap.
• Introduction to Logical Volume Manager (LVM)
• How to create and manage Logical Volume Manager (LVM)
• Introduction to Redundant Array of inexpensive (or Independent) Disks (RAID)
• How to create and manage Redundant Array of Inexpensive Disks (RAID)
• How to create and manage swap space