Leif160519的blog Leif160519的blog

——————

目录
解决ubuntu在老平台上死机的问题
/  

解决ubuntu在老平台上死机的问题

ubuntu速度慢的原因之内存和swap分区
我在日常使用ubuntu时,经常要同时打开10几个窗口和应用,有时候就会发生速度变得很慢的情况,甚至系统明显反应迟钝,这时一般是物理内存不够用,系统开始用换硬盘上的swap分区做虚拟内存,其速度可想而知。
在ubuntu里面往往不是物理内存全部耗尽采取使用swap分区,swappiness的值的大小对如何使用swap分区是有着很大的联系的。swappiness=0的时候表示最大限度使用物理内存,然后才是 swap空间,swappiness=100的时候表示积极的使用swap分区,并且把内存上的数据及时的搬运到swap空间里面。两个极端,对于ubuntu的默认设置,这个值等于60,建议修改为10。具体这样做:
1.查看你的系统里面的swappiness

cat /proc/sys/vm/swappiness

不出意外的话,你应该看到是 60

2.修改swappiness值为10

sudo sysctl vm.swappiness=10

但是这只是临时性的修改,在你重启系统后会恢复默认的60,所以,还要做一步:

重点!!!:

sudo gedit /etc/sysctl.conf

在这个文档的最后加上这样一行:

vm.swappiness=10

重点:kernel flag加上:

processor.max_cstate=1 intel_idle.max_cstate=0

方法:sudo nano /etc/default/grub
修改这个参数,在引号内以空格分割,加上processor.max_cstate=1

intel_idle.max_cstate=0

最后效果:GRUB_CMDLINE_LINUX="processor.max_cstate=1 intel_idle.max_cstate=0"
然后update-grub
然后sudo reboot


“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill

标  题解决ubuntu在老平台上死机的问题
作  者Leif160519
出  处https://github.icu/articles/2019/08/22/1566472477352.html
关于博主:坐标南京,运维工程师,如有问题探讨可以直接下方留言。
声援博主:如果您觉得文章对您有帮助,可以评论、订阅、收藏。您的鼓励是博主的最大动力!