**:
無論是windows系統還是linux系統,除了物理記憶體外,都還有乙個虛擬記憶體。在linux上,虛擬記憶體被稱為swap space。過去以來,虛擬記憶體的大小應該是物理記憶體的兩倍,但是最近幾年來,物理記憶體的大小至少都有了好幾個gb,如果16g記憶體用32g的swap豈不是太占用硬碟空間?
下圖是虛擬記憶體和交換空間的對映關係,虛擬記憶體的存在,可以提高電腦的執行速度,所以其存在很有意義。
我們看看redhat的官方答覆是怎麼說的:
amount of ram in the system 物理記憶體
recommended swap space建議的交換空間大小
recommended swap space if allowing for hibernation如果開啟休眠功能建議的交換空間大小
⩽ 2gb
2 times the amount of ram
3 times the amount of ram
> 2gb – 8gb
equal to the amount of ram
2 times the amount of ram
> 8gb – 64gb
at least 4 gb
1.5 times the amount of ram
> 64gb
at least 4 gb
hibernation not recommended
總結起來就是,如果不打算開啟休眠功能,物理內存在8g以下,則swap設定為與物理記憶體一樣大。如果物理內存在8g以上,swap空間設定為8g即可。當物理記憶體大於64g時,不建議開啟休眠功能。
以下是ubuntu的指南,更加細緻:(從左至右依次是ram大小,不開啟休眠,開啟休眠,最大值)
ram(mb) no hibernation with hibernation maximum
256 256 512 512
512 512 1024 1024
1024 1024 2048 2048
ram(gb) no hibernation with hibernation maximum
1 1 2 2
2 1 3 4
3 2 5 6
4 2 6 8
5 2 7 10
6 2 8 12
8 3 11 16
12 3 15 24
16 4 20 32
24 5 29 48
32 6 38 64
64 8 72 128
128 11 139 256
參考鏈結如下: 增加Linux的Swap空間
在linux下安裝oracle的時候,提示沒有swap space,按以下方法增加。環境 ceontos6.9 執行步驟 1 檢查 swap 空間是否有設定。執行命令 swapon s如果返回為空,表示 swap 檔案不存在。2 檢查檔案系統,看是否有足夠的硬碟空間來設定 swap 執行命令 df ...
linux 擴充SWAP空間
一 建立pv root rac1 pvcreate dev sda3 physical volume dev sda3 successfully created 二 擴成vg root rac1 vgextend volgroup00 dev sda3 dev hdc open failed rea...
linux 增加swap空間
root localhost free m 檢視swap容量 total used free shared buffers cached mem 1006 969 36 0 9 467 buffers cache 492 514 swap 2015 32 1983 root localhost dd...