Swap partition, that is, swap zone. The role of swap space can be simply described as: when the physical memory of the system is insufficient, a part of the physical memory needs to be released, for the currently running program. The released space may come from some programs that haven't been operated for a long time. The released space is temporarily saved to the Swap space and will be executed by those programs, then, the stored data is restored from Swap to the memory.
In this way, the system always performs Swap switching when the physical memory is insufficient. In fact, Swap adjustment is crucial to the performance of Linux servers, especially Web servers. By adjusting Swap, the system performance bottleneck is sometimes crossed to save system upgrade costs.
When the physical memory is less than 2 GB, the size of the swap partition is twice that of the physical memory. For a part larger than 2 GB, the swap partition size is equal to the physical memory size.
That is, the following formula is obtained:
X <= 2g, y = 2x
X> 2G, y = x
Using this formula, 2G physical memory requires 4G swap, while 3G physical memory requires 5G swap. If you want to add memory, it is helpful to create a larger swap zone.
For example, if your swap partition exceeds 2 GB according to the partition plan, you should create another swap partition. For example, if you need a 4G swap partition, you should create two 2G swap partitions.
If there is 4 GB physical memory, 6 GB swap partition is required according to the formula:
2x2 GB = 4G 1x2 GB = 2G the sum of the above two. 6 GB in total)
Each swap partition is 2 GB. Create 3 2G swap partitions.
Redhat EL supports up to 32 swap files.
For more than 32 GB physical memory, it is better to use a swap partition smaller than or equal to the physical memory capacity.