Linux SWAP 交换分区配置说明

一.SWAP 说明

1.1 SWAP 概述


这个是SWAP 交换分区的作用。实际上,我们更关注的应该是SWAP分区的大小问题。 设置多大才是最优的。


4G以内的物理内存,SWAP 设置为内存的2倍。

4-8G的物理内存,SWAP 等于内存大小。

8-64G 的物理内存,SWAP 设置为8G。

64-256G物理内存,SWAP 设置为16G。


1.2 系统在什么情况下才会使用SWAP?

实际上,并不是等所有的物理内存都消耗完毕之后,才去使用swap的空间,什么时候使用是由swappiness 参数值控制。

[root@rhce ~]# cat /proc/sys/vm/swappiness



swappiness=0的时候表示最大限度使用物理内存,然后才是 swap空间,



1.3 如何修改swappiness参数?


[root@rhce ~]# sysctl vm.swappiness=10

vm.swappiness = 10

[root@rhce ~]# cat /proc/sys/vm/swappiness




在/etc/sysctl.conf 文件里添加如下参数:



[root@rhce ~]# echo ‘vm.swappiness=10’>> /etc/sysctl.conf


14 thoughts on “Linux SWAP 交换分区配置说明

  1. Hello, Neat post. There is an issue together with your site in web
    explorer, would check this? IE nonetheless is the market leader
    and a huge component to other folks will pass over your wonderful
    writing because of this problem.

  2. It’s appropriate time to make some plans for the long run and it’s time to be happy.
    I’ve learn this submit and if I may just I want to recommend
    you few interesting things or suggestions. Maybe you could write
    subsequent articles relating to this article. I want to learn more issues about it!

  3. I must thank you for the efforts you have put in penning this blog.

    I’m hoping to see the same high-grade blog posts from you in the future
    as well. In truth, your creative writing abilities has encouraged me to get my very own site now 😉

  4. Howdy this is somewhat of off topic but I was wanting to know if blogs use WYSIWYG editors or if you have to manually code with HTML. I’m starting a blog soon but have no coding knowledge so I wanted to get advice from someone with experience. Any help would be greatly appreciated!

Leave a Reply

Your email address will not be published. Required fields are marked *