当前位置: 首页>>技术问答>>正文


我如何使用zRam?

, , ,

问题描述

我按照webupd8.org中的描述安装了zRam。我从终端安装了它。这就是我必须要做的事情或做什么我必须做一些配置或什么? zram-enabler是单独完成所有操作还是必须设置一些参数?

最佳解决方法

就像Sergey “Shnatsel” Davidoff在该博客文章中引用的那样,该软件包安装了一个脚本来将其作为服务运行。该脚本自动配置自身,服务自动启动。无需进一步配置。该服务可以通过以下方式手动控制:

sudo service zramswap start|stop|status|restart|reload|force-reload

如果您使用文件滚轮打开deb软件包,您可以看到只安装了两个文件:

/etc/init/zramswap.conf
/etc/init.d/zramswap

以及一些文档文件。 DEBIAN目录包含包元数据和用于初始化服务的命令。这就是包中的所有内容。相应的设备以此方案命名:/dev/zram[0-9]

你通过PPA安装了吗?我建议这样做。

次佳解决方法

在这里,您可以在Ubuntu中了解zRam:

zRam is a code inside kernel, that once activated, creates a RAM based block device which acts as a swap disk, but is compressed and stored in memory, allowing very fast I/O and increasing the amount of memory available before the system starts swapping to disk.

zRam is integrated into the Linux kernel 3.2 and above, so it’s included already in Ubuntu 12.04.

Previously on my 2GB machine, without zRAM, when i open lots of browser tabs, the system start choking, while HDD start copying data to SWAP causing a total slowdown. Now after activating zRam, instead of freezing after running out of RAM, the system worked like nothing happened. I didn’t notice any difference at all. It looked just like adding more RAM 😉

From my experience, zRam is useful for people using computers with 1GB or 2GB RAM. Since zRam is compressing data, it require some processor resources. Not much, but always. For that reason i do not recommend to use it with old processors. Also if you have 4GB RAM most likely it won’t be necessary to use it.

To activate it, type in terminal:

sudo apt-get install zram-config 

To remove [type the following]:

sudo dpkg --purge zramswap-enabler sudo dpkg --purge zram-config 

第三种解决方法

服务守护程序将在安装后立即激活。您可以通过键入终端来验证这一点:

cat /proc/swaps

应该有一些/dev /XXX条目(假设您有一个交换分区/文件处于活动状态)并且至少有一个条目名称为”swap”(我们的系统上每个处理器核心都有一个条目)。如果没有,请尝试重新启动并再次输入命令。

没有必要采取进一步行动。

第四种方法

从Ubuntu Precise开始,Adam Conrad有一个官方的Ubuntu新手脚本在主存储库中配置zram:

sudo apt-get install zram-config

资料来源:http://gionn.net/2012/03/11/zram-on-debian-ubuntu-for-memory-overcommitment/

第五种方法

确保reboot Ubuntu并检查Zram是否在启动期间启动。

按照前面提到的说明进行操作,以便通过cat /proc/swaps进行检查

如果您没有看到列出的zram交换设备(在我的情况下也是如此),请执行以下操作:

sudo su  
update-rc.d zramswap defaults

这将列出zram作为启动服务。

reboot并检查它是否在启动期间启动。

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/1897.html,未经允许,请勿转载。