Article Title: linux swap Partition Rules. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
(The following is an official copy of Redhat)
Swap shoshould equal 2x physical RAM for up to 2 GB of physical RAM, and then 1x physical RAM for any amount above 2 GB, but never less than 32 MB.
Using this formula, a system with 2 GB of physical RAM wowould have 4 GB of swap, while one with 3 GB of physical RAM wowould have 5 GB of swap. creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time.
Tip
If your partitioning scheme requires a swap partition that is larger than 2 GB, you should create an additional swap partition. for example, if you need 4 GB of swap, you should create two 2 GB swap partitions. if you have 4 GB of RAM, you should create three 2 GB swap partitions. red Hat Enterprise Linux supports up to 32 swap files.
For systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM ).
The approximate meaning is:
When the physical memory is less than 2 GB, the swap size is twice the physical memory size. The size of the swap is equal to that of the physical memory.
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 4 GB of physical memory is available, 6 GB of swap 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 area smaller than or equal to the physical memory capacity.