選單 Menu
計數器 Counter
TODAY : 181181181
YESTERDAY : 292292292
TOTAL : 1315826131582613158261315826131582613158261315826
網頁知識 : Real memory與Swap space
作者 設計師 於 2015年08月03日 20:03:13 (3887 次閱讀)

真實記憶體與交換區

當Linux的交換空間使用時的物理內存(RAM)的量是滿的。如果系統需要更多的內存資源和內存已滿,內存中不活躍的頁面會被移動到交換空間。雖然交換空間可以幫助機器用少量的RAM,它不應該被認為用來替代更多的RAM。交換空間位於硬碟上,它比物理內存讀取時間要慢。



What is Swap Space?

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.

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 + 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. 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).

Important

File systems and LVM2 volumes assigned as swap space cannot be in use when being modified. For example, no system processes can be assigned the swap space, as well as no amount of swap should be allocated and used by the kernel. Use the free and cat /proc/swaps commands to verify how much and where swap is in use.
The best way to achieve swap space modifications is to boot your system in rescue mode, and then follow the instructions (for each scenario) in the remainder of this chapter. Refer to the Red Hat Enterprise Linux Installation Guide for instructions on booting into rescue mode. When prompted to mount the file system, select Skip.