Skip to content
Scripts that enable zram for Fedora
Shell Makefile
Latest commit f662370 May 14, 2016 @mystilleef Merge pull request #22 from Zecas/master
Use nproc to count cpus
Failed to load latest commit information.
.gitignore Add ignore file for temp/dist files/directories. Mar 19, 2013
.project Add Eclipse project file. Feb 28, 2013
Makefile Version 1.0.1 Apr 9, 2016
README.md update README to use mkzram.service Nov 30, 2015
mkzram.service Activate service at swap.target Jun 5, 2015
zram Use 33% RAM for swap (was 90%). Works best for my laptop. Mar 19, 2013
zram.spec Rename zram.service to mkzram.service to avoid conflict with Anaconda… May 16, 2015
zramstart Use nproc to count processors Apr 9, 2016
zramstat
zramstop Simplify zramstop (just check /proc/swaps, don't count CPUs...). Mar 19, 2013

README.md

zram for Fedora

zram compresses swap partitions into RAM for performance.

You need Linux kernel version 2.6.37.1 or better to use zram. For Fedora 16 you can just install kmod-staging from rpmfusion to get the module:

sudo yum install kmod-staging

Automated Install

First you have to setup your rpm build environment. For details see How to create an RPM package - Preparing your system.

# Short version of the howto
sudo yum install @development-tools fedora-packager
rpmdev-setuptree

# the real thing(tm)
make rpm
sudo rpm -Uhv ~/rpmbuild/RPMS/noarch/zram-*.noarch.rpm

Manual Install

There are 4 files you need to enable zram for Fedora. They are:

  • zramstart
  • zramstat
  • zramstop
  • mkzram.service

All these files can be found in the project directory.

Place "zramstart", zramstat and "zramstop" in the following directory.

/usr/sbin/

Place "mkzram.service" in the following directory.

/lib/systemd/system

Place "zram" in the following directory.

/etc/sysconfig

As root, run the following command to enable zram for Fedora.

systemctl daemon-reload

Starting

sudo systemctl enable mkzram.service
sudo systemctl start mkzram.service

Run the following command to make sure the service started properly.

sudo systemctl status mkzram.service

The output should look like this:

mkzram.service - Enable compressed swap in memory using zram
    Loaded: loaded (/usr/lib/systemd/system/mkzram.service; enabled)
    Active: active (exited) since Mon 2015-11-30 12:26:21 UTC; 2min 45s ago
    Process: 2437 ExecStart=/usr/sbin/zramstart (code=exited, status=0/SUCCESS)
    Main PID: 2437 (code=exited, status=0/SUCCESS)

To see how well your compressed swap performs run

zramstat # no sudo needed

The output looks like this:

/dev/zram0:     362.18% (180998144 -> 49973309)
/dev/zram1:     356.50% (180924416 -> 50749160)

This means 180,998,144 bytes got compressed to 49,973,309 bytes. The "swapped" memory is 362.18% of the RAM used. That's it!

Credits:

The zramstart and zramstop scripts were written by Sergey Davidoff of Elementary OS. The zramstat script and RPM packaging bits by Doncho N. Gunchev.

References:

Something went wrong with that request. Please try again.