A swap partition (at least 256 MB) — swap
partitions are used to support virtual memory. In other words, data is written
to a swap partition when there is not enough RAM to store the data your system
is processing.
If you are unsure about what size swap partition to create, make it twice the
amount of RAM on your machine. It must be of type swap.
Creation of the proper amount of swap space varies depending on a number of
factors including the following (in descending order of importance):
1. The applications running on the machine.
2. The amount of physical RAM installed on the machine.
3. The version of the OS.
Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an
additional 1x physical RAM for any amount above 2 GB, but never less than 32
MB.
so, if:
M = Amount of RAM in GB, and S = Amount of swap in GB, then
If M < 2
S = M * 2
Else
S = M + 2G
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. Creating a large
swap space partition can be especially helpful if you plan to upgrade your RAM
at a later time.
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).
RHEL的官方文档,这是针对服务器的:
目前RedHat推荐交换分区的大小应当与系统物理内存的大小保持线性比例关系。不过在小于2GB物理内存的系统中,交换分区大小应该设置为内存大小的两
倍,如果内存大小多于2GB,交换分区大小应该是物理内存大小加上2GB。其原因在于,系统中的物理内存越大,
对于内存的负荷可能也越大。
但是,如果物理内存大小扩展到数百GB,这样做就没什么意义了。
实际上,系统中交换分区的大小并不取决于物理内存的量,而是取决于系统中内存的负荷。Red Hat Enterprise Linux5可以在这样的情况下工作:完全没有交换分区,而且系统中匿名内存页和共享内存页小于3/4的物理内存量。在这种情况下,系统会将匿名内存页和
共享内存页锁定在物理内存中,而使用剩余的物理内存来缓冲文件系统数据(pagecache),当内存耗尽时,系统内核只会回收利用这些 pagecache内存。
考虑到以下情况:
1)安装系统时难以确定内存的负荷,如何设置交换分区大小
2)系统中物理内存越大,所需交换分区就会越少
因此,在Red Hat Enterprise Linux 5中,以下是设置合适的交换分区大小的规则:
小于等于4G物理内存的系统,至少设置2GB的交换分区
4G~16G物理内存的系统,至少设置4GB的交换分区
16G~64G物理内存的系统,至少设置8GB的交换分区
16G~256G物理内存的系统,至少设置16GB的交换分区
阅读(3970) | 评论(0) | 转发(0) |