Package Details: zramswap 1.1-1

Git Clone URL: https://aur.archlinux.org/zramswap.git (read-only)
Package Base: zramswap
Description: Sets up zram-based swap devices on boot
Upstream URL: http://en.wikipedia.org/wiki/ZRam
Licenses: GPL
Submitter: Svenstaro
Maintainer: rpodgorny
Last Packager: rpodgorny
Votes: 194
Popularity: 1.498781
First Submitted: 2011-10-05 23:35
Last Updated: 2015-06-14 19:57

Dependencies (1)

Required by (0)

Sources (2)

  • zramctrl
  • zramswap.service

Latest Comments

Anakon commented on 2015-10-08 11:27

May I suggest to use the nproc command to get cpucount instead of parsing /proc/cpuinfo ?
For example on an Odroid C1 this leads to a wrong number of 5 :
$ cat /proc/cpuinfo
Processor : ARMv7 Processor rev 1 (v7l)
processor : 0
BogoMIPS : 3.27

processor : 1
BogoMIPS : 3.27

processor : 2
BogoMIPS : 3.27

processor : 3
BogoMIPS : 3.27

Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc05
CPU revision : 1

Hardware : ODROIDC
Revision : 000a
Serial : 1b00000000000000

bluerider commented on 2015-04-06 17:48

I have taken your advice and have started my own package:
<https://aur.archlinux.org/packages/zswap/>

bluerider commented on 2015-04-06 01:25

I recommended it for replacement because it solves several things with the current zramswap script:
1) uses zramctl
2) allows the existence of zram devices beforehand
3) removes only swap zram devices when called to stop
4) suppports effcient swap reset
5) allows different parameters for each zram module.

-- the +2 is to ensure there are 2 free zram devices for other purposes
-- the /7 is because the output has 7 lines per zram devices when using bash.

rpodgorny commented on 2015-04-06 00:04

nice, and:

1) i suggest you create a separate package with the -git suffix as per https://wiki.archlinux.org/index.php/VCS_package_guidelines

2) looking at your scripts, it seems to be configured by editing the .sh file directly. this is a general no-no and should be changed to source the config from /etc.

3) just as a quality of code improvement recommendation, you should document your code more - at least the magical constants (num_devices+2, ...raw))/7, ...).

bluerider commented on 2015-04-05 20:36

# Contributor: ifaigios <ifaigios_at_gmail_dot_com>
# Contributor: Alyssa Hung <deciare@isisiew.org>
# Contributor: Matt Brennan
# Contributor: falconindy
# Contributor: adee
# Contributor: mystilleef
# Contributor: Mark Lee <mark@markelee.com>

pkgname=zramswap
pkgver=2
pkgrel=1
pkgdesc="Sets up zram-based swap devices on boot"
arch=('any')
url="https://github.com/bluerider/zramswap.git"
license=('MIT')
depends=('bash' 'util-linux')
makedepends=('git')
source=("git+$url")
sha256sums=('SKIP')

package() {
install -Dm755 "${srcdir}/${pkgname}/zramswap.sh" "${pkgdir}/usr/lib/systemd/scripts/zramswap.sh"
install -Dm644 "${srcdir}/${pkgname}/zramswap.service" "${pkgdir}/usr/lib/systemd/system/zramswap.service"
}

bluerider commented on 2015-04-05 20:33

I made my own version using zramctl. I think it's significantly more robust this script. You want to use mine instead? It's MIT licensed.

The needed files are at : <https://github.com/bluerider/zramswap/tree/master>

In addition, I have a working PKGBUILD :

# Contributor: ifaigios <ifaigios_at_gmail_dot_com>
# Contributor: Alyssa Hung <deciare@isisiew.org>
# Contributor: Matt Brennan
# Contributor: falconindy
# Contributor: adee
# Contributor: mystilleef
# Contributor: Mark Lee <mark@markelee.com>

pkgname=zramswap
pkgver=2
pkgrel=1
pkgdesc="Sets up zram-based swap devices on boot"
arch=('any')
url="https://github.com/bluerider/zramswap.git"
license=('GPL')
depends=('bash' 'util-linux')
makedepends=('git')
source=("git+$url")
sha256sums=('SKIP')

package() {
install -Dm755 "${srcdir}/${pkgname}/zramswap.sh" "${pkgdir}/usr/lib/systemd/scripts/zramswap.sh"
install -Dm644 "${srcdir}/${pkgname}/zramswap.service" "${pkgdir}/usr/lib/systemd/system/zramswap.service"
}

rpodgorny commented on 2015-03-05 11:38

probably because zramctl was non-existent at the time this package got created...

still, peeking quicky at the current solution, there doesn't seem to be much more than modprobe+mkswap+swapon which is the same as systemd-swap uses for zram.

zramctl is used there only at the "stop" phase (why not in the "start"?):
https://github.com/Nefelim4ag/systemd-swap/blob/master/systemd-swap.sh

...but i might be mistaken - feel free to correct me. patches are welcome and i'll be happy to merge them.

AJSlye commented on 2015-03-01 12:04

I agree with bluerider, zramctl is already in the Community repository as is systemd-swap. Why not just make a pkgbuild script to install, setup and use these two already existing packages.

bluerider commented on 2014-09-29 20:29

Is there a reason why this script doesn't just use zramctl?

Nefelim4ag commented on 2014-08-19 21:17

Change type unit to simple, improve system start time, and not break zramswap script.

[Unit]
Description=Zram-based swap (compressed RAM block devices)

[Service]
ExecStart=/usr/lib/systemd/scripts/zramctrl start
ExecStop=/usr/lib/systemd/scripts/zramctrl stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Nefelim4ag commented on 2014-07-30 17:10

@beta990: only for swapping
You can use it for tmp by aur/zram or by handwork script.

francoism commented on 2014-07-30 15:45

@nariox: Thanks for your information. :)
About this package: can I use it for creating a custom location for storing (tmp) files into the memory? Or is this only for swapping?

nariox commented on 2014-07-30 15:12

@beta990: zram is a kernel module, you don't neet this package to use it. This package (zramswap) includes scripts to automatically enable zram on boot. To enable/use it you should do:
# systemctl enable zramswap
# systemctl start zramswap

francoism commented on 2014-07-30 15:00

Hello,

I'm not exactly know how to use this tool (correctly).

dmesg:
zram: Created 2 device(s) ...
zram0: detected capacity change from 0 to 832368640
zram1: detected capacity change from 0 to 832368640
Adding 812856k swap on /dev/zram0. Priority:100 extents:1 across:812856k SSFS
Adding 812856k swap on /dev/zram1. Priority:100 extents:1 across:812856k SSFS

Can I now mount /dev/zram0? Do I need to format it first?
I'm looking here: https://www.kernel.org/doc/Documentation/blockdev/zram.txt
But I don't know if they are the same.

Thanks! :)

Nefelim4ag commented on 2014-07-12 19:40

For zram, instead of use several zram devices for multithreading, we can use /sys/block/zram*/max_comp_streams
Also, i write external tool https://github.com/Nefelim4ag/zramctl for managment zram devices, i think it can be helpful for this script.

nariox commented on 2014-06-30 17:14

That's a good point (specially for people who need to use older kernels for some reason). If we put a if clause that checks whether COMP is set before setting the compression algorithm. This way we can keep both options.

Either way, the "right way" to do this would be by creating a /etc/default/zramswap file where these settings would be set (instead of editing the systemd script directly).

What do you think?

rpodgorny commented on 2014-06-24 21:47

hi nariox!

thanks for the patch. i'll be happy to include it but i don't think we should override the kernel-set default. would it be possible to make the compression algorithm selection optional (leaving the default up to the kernel)?

thanks!

nariox commented on 2014-06-21 23:25

Hey guys, thanks for the good work.
Since linux 3.15, we can use lz4 as the compression algorithm for zram. While some benchmarks show that lz4 is not much faster than lzo, I thought it might be worth adding it as default. I've made a patch for zramctrl that makes it easy to switch between the two. You can get it at : http://pastie.org/9312716

melodie commented on 2014-05-26 13:32

Hello,

To rpodgorny: thanks a lot! For giving your word and also for taking the maintainer-ship!

(You can see my comment from "2014-05-21 22:39" and the ones I answered after).

Regards,
Mélodie

rpodgorny commented on 2014-05-25 12:19

thank you!

Nefelim4ag commented on 2014-05-25 12:15

Okay, i revert old package from there.
http://pkgbuild.com/git/aur-mirror.git/tree/zramswap?id=eb801b8fd234cd615edcd5f4d7ab0b627f163c24
Enjoy it.

Nefelim4ag commented on 2014-05-25 12:14

Okay, i revert old package from there
http://pkgbuild.com/git/aur-mirror.git/tree/zramswap?id=eb801b8fd234cd615edcd5f4d7ab0b627f163c24
Enjoy

rpodgorny commented on 2014-05-25 10:45

whoa! what the hell is this? did you really just overwrite this package with systemd-swap?

this is a major NO-NO!

1) the packages may be an obsolete mess but still it's working and deserves to exist.
2) systemd-swap is a completely different implementation with completely different settings system and completely different features.
3) the votes zramswap has accumulated over time were for the original implementation, not the new one.
4) systemd-swap is not ready for prime time, yet.

...so, please keep systemd-swap in systemd-swap and return the original zramswap here. i have no problem taking over the maintanership.

thank you!

karol_007 commented on 2014-05-23 09:51

systemd-swap has just been moved to [community] https://projects.archlinux.org/svntogit/community.git/log/trunk?h=packages/systemd-swap

swiftgeek commented on 2014-05-22 03:13

Do You even know about what AUR package You are commenting on?
http://pkgbuild.com/git/aur-mirror.git/tree/zramswap/zramctrl?id=eb801b8fd234cd615edcd5f4d7ab0b627f163c24
This happened to sit here for YEARS :< AFAIR it was provided by falconidy as part of bigger package of scripts for systemd in its early days, and few months later dropped to AUR
---
Zramswap is custom arch-specific script from eons ago. systemd-swap is mostly a clean rewrite of that with a new name that is more accurate than zramswap. Also new features and better config!

melodie commented on 2014-05-22 02:48

swiftgeek,

I have not been impolite to you so please treat me well too.

« This package doesn't provide anything beyond that script.»

So be it, and please don't feed me with "systemd-swap" telling me it's name is "zramswap". This is not right.


→ So would you want to have codes and references?

Some points to be sure you get it:
- replacing a program/feature by a new set of features **with the same name** is not the way to go: imho.

- I don't know what is wrong about using awk? The first scripts I was handed over to use compcache did use some awk commands too:
https://code.google.com/p/compcache/

The first scripts I used when I have pointed to the zram method many years ago, was a set of lines in a rc.local file. At this time it had been added to a distribution where people had never heard of it yet (around 2010). zRAM was not yet even a kernel module.

Why do you want me to read comments? I have gone to read the github page you pointed me to, I have discovered there that keenerd has added a patch not so long ago: last year during summer.

Code to read? Let's read code together will you? Here is the code from mystillef:
http://mystilleef.blogspot.fr/2011/10/enable-zram-in-fedora.html

other former codes:
http://bazaar.launchpad.net/~elementary-os/elementaryos/zramswap-enabler/view/head:/debian/zramswap.upstart

oh do you notice? No awk here! ;)

In Mystillef scripts there is one awk command : in the zramstop script (you can unpack the archive provided to check).

In the script I used back a few years ago before the first zram kernel module was delivered, there is a also one awk command, right in the second of these two lines:
***************

gprintf "Sizing zram swap device\n"

FREE_MEM=`free -t -m | egrep Mem | awk {'print $2'}`

***************

I was using a "awk" script?! I didn't even know it!

If I understand well the __real issue__ here would be that you have been the packager, and you don't want to maintain it anymore? Maybe someone else will want to continue maintaining it? So please don't hurry and don't throw the baby with the bath.

swiftgeek commented on 2014-05-22 02:15

@melodie WTF⁵⁰⁰
Script for this package used zram devices for swap and nothing else. End of story. This package doesn't provide anything beyond that script.
NOBODY brought anything more than idea (remember this was an »awk« script) and now new script with new name provides everything mentioned before and more!
And nobody is forcing anyone to use any particular swap technique - and that's a change from old script!
FFS please read comments, code (both! old and new), don't FUD etc.

melodie commented on 2014-05-22 01:31

Hi,

Other people might want to bring their idea about it before you decide?

For myself I know that zram is a kernel module which is originally part of the compcache project.

I also know that with _some_ configurations done in the _kernels_ it has sometimes brought freeze trouble in systems, or just hang during boot instead of being loaded, and this, until the specific configuration in the kernel was modified (I'll bring a link from an Ubuntu bug as example here: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1246664 and the fix provided at this point of the discussion: comment #58), I say, just to make a point about this part: the zRAM kernel module is NOT the same as a swap file.

Else, the debate running about swapping methods and the different caches existing continues to run among people who work around the kernels and also among the people who perform benchmarks around these features.

What is wrong with the original zramswap script?

swiftgeek commented on 2014-05-22 00:12

If anynone would read the comments or checked aur's git would know that:
• zramswap is the old unmaintainable awk script that was going to be rewritten to bash since ever and systemd-swap IS that rewrite with changed name, author and maintainer (so it was good for me to be lazy, because this rewrite is much better than the one i would make)

• using zram for swap is mostly the same as using file for swap -.- just compressed and lives inside ram

• while it's possible to read what old script was doing, improving it isn't feasible - nobody since months and years even tried to do anything mayor with that script and every change made to it was painful and extremely time consuming
http://pkgbuild.com/git/aur-mirror.git/tree/zramswap/zramctrl?id=eb801b8fd234cd615edcd5f4d7ab0b627f163c24

Nefelim4ag commented on 2014-05-21 22:51

@melodie
You're like Sherlock ;)
I have conversation with old maintainer "Swift Geek", and i suggest to remove this package. He explained that can not leave people with orphaned package. And for find solution, we must find compromise.
This package it compromise, he leave orphan package, i adopt him. I notified people in comment and post_install.

Copy of comment:
Comment by Nefelim4ag

2014-05-21 13:12

From now, this is duplicate of https://aur.archlinux.org/packages/systemd-swap/ package, for not leave users with orphan package (zramswap).
Anybody, how read this, please install systemd-swap instead zramswap. Because zramswap is dead and be deleted from aur in few months.

melodie commented on 2014-05-21 22:45

PS: this page is not the right one:
https://aur.archlinux.org/packages/sy/systemd-swap/

this one is:
https://aur.archlinux.org/packages/systemd-swap/

melodie commented on 2014-05-21 22:44

PS: the page here does not exist:
https://aur.archlinux.org/packages/sy/systemd-swap/

but the page here does:
https://aur.archlinux.org/packages/sy/systemd-swap/PKGBUILD

:-|

melodie commented on 2014-05-21 22:39

Hi,

This package is NOT zramswap: I have just seen my aur package manager submit an update for the zramswap program I have been using for such a long time, and I have been very surprised to read the description in the PKGBUILD:
**********
pkgdesc="This is script for creating hybrid swap space from zram swaps, swap files and swap partitions. Swap file - auto create dinamic growing swap file and mount it via loop. For enable: sudo systemctl enable systemd-swap. Config in /etc/systemd-swap.cfg"

**********

Whereas the description for the zramswap (version 1.1.1) which is installed into my system is:

**********
"Description : Sets up zram-based swap devices on boot"

**********

I am not saying that your systemd-swap program is not good, I don't know it, but I DISAGREE STRONGLY about the process that consists in providing it as if it were zramswap ITSELF : this seems to me very close to dishonest. :-(

You program being also here:
https://aur.archlinux.org/packages/sy/systemd-swap/

and the PKGBUILD:
https://aur.archlinux.org/packages/sy/systemd-swap/PKGBUILD

shows this different between the *present* zramswap and the one *systemd-swap*:

diff =
< pkgname=zramswap
> pkgname=systemd-swap

Here is what the **zramswap** script installed here does and which works a treat as we can see:
******************
$ cat /proc/swaps
Filename Type Size Used Priority
/dev/sda5 partition 4607996 0 -1
/dev/zram0 partition 506528 0 100
/dev/zram1 partition 506528 0 100


*******************


and here is the content of the script:
*******************
$ cat /usr/lib/systemd/scripts/zramctrl
#!/bin/sh


start() {
exec awk -v ZRAM_SIZE=$ZRAM_SIZE '

FILENAME == "/proc/cpuinfo" && ($1 == "processor" || $1 == "Processor") {
cpucount++
next
}

FILENAME == "/proc/meminfo" && $1 == "MemTotal:" {
if (ZRAM_SIZE == "")
ZRAM_SIZE = 20
mem_total = int( (0 + $2) * 1024 * ( ZRAM_SIZE/100 ) )
next
}

END {
mem_per_cpu = int(mem_total / cpucount)

system("modprobe zram num_devices=" cpucount)

for (i = 0; i < cpucount; i++) {
print mem_per_cpu > "/sys/block/zram" i "/disksize"
system("mkswap /dev/zram" i " -L zram" i)
swapdevs = swapdevs " /dev/zram" i
}

system("swapon -p 100" swapdevs)
}
' /proc/cpuinfo /proc/meminfo
}

stop() {
exec awk '
FNR > 1 && $1 ~ /^\/dev\/zram[0-9]+$/ {
activeswaps = activeswaps " " $1
}

END {
system("swapoff" activeswaps)
system("rmmod zram")
}
' /proc/swaps
}

case $1 in
start|stop) "$1" ;;
esac

***********

and it's start file:
***********

$ cat /usr/lib/systemd/scripts/zramctrl
#!/bin/sh


start() {
exec awk -v ZRAM_SIZE=$ZRAM_SIZE '

FILENAME == "/proc/cpuinfo" && ($1 == "processor" || $1 == "Processor") {
cpucount++
next
}

FILENAME == "/proc/meminfo" && $1 == "MemTotal:" {
if (ZRAM_SIZE == "")
ZRAM_SIZE = 20
mem_total = int( (0 + $2) * 1024 * ( ZRAM_SIZE/100 ) )
next
}

END {
mem_per_cpu = int(mem_total / cpucount)

system("modprobe zram num_devices=" cpucount)

for (i = 0; i < cpucount; i++) {
print mem_per_cpu > "/sys/block/zram" i "/disksize"
system("mkswap /dev/zram" i " -L zram" i)
swapdevs = swapdevs " /dev/zram" i
}

system("swapon -p 100" swapdevs)
}
' /proc/cpuinfo /proc/meminfo
}

stop() {
exec awk '
FNR > 1 && $1 ~ /^\/dev\/zram[0-9]+$/ {
activeswaps = activeswaps " " $1
}

END {
system("swapoff" activeswaps)
system("rmmod zram")
}
' /proc/swaps
}

case $1 in
start|stop) "$1" ;;
esac

************

I would like it to stay that way, until it is itself in need of an update for any technical reason and I don't see any reason to change now. No freeze, no issue of any kind, on a fully up to date system.

Please let systemd-swap be a new one and zramswap keep it's place!

Thanks.


gourdcaptain commented on 2014-05-21 21:59

I might also note that systemd-swap's a bit more general purpose script and they may want to disable the other components in the config file. (I'm a guy using the zram swap for a overpowered netbook with 8 GB of RAM and a tiny SSD as a security margin in case I somehow run out of RAM, but I don't want actual swap because I don't want the wear and tear on the SSD.

Nefelim4ag commented on 2014-05-21 20:04

@thiagowfx
Thanks, i add post install information.

thiagowfx commented on 2014-05-21 18:57

Hi, I just updated zramswap from 1.x to 2.x. Fortunately I come to this page to see the differences.

I'd recommend you to add a post_install message so current users could see they should move to systemd-swap. Thanks!

Nefelim4ag commented on 2014-05-21 13:12

From now, this is duplicate of https://aur.archlinux.org/packages/systemd-swap/ package, for not leave users with orphan package (zramswap).
Anybody, how read this, please install systemd-swap instead zramswap. Because zramswap is dead and be deleted from aur in few months.

Nefelim4ag commented on 2014-05-21 11:53

@orschiro
Yes, systemd-swap cover zramswap functionally, also he full written on bash.
Systemd-swap is combine for managing swap spaces.

orschiro commented on 2014-05-21 05:07

@Nefelim4ag

Thanks, systemd-swap has more or less the same functionality as zramswap, correct?

swiftgeek commented on 2014-05-20 21:08

Orphaned for Nefelim4ag

Nefelim4ag commented on 2014-05-20 20:42

Try use https://aur.archlinux.org/packages/systemd-swap/

swiftgeek commented on 2014-04-08 20:47

script is in hiatus and doesn't met expectation of present times, is written in awk (strange choice)

besides that i maintain this package to at least maintain functionality of this awk script, which is *very* limited…

Also not having any paid job atm doesn't help either in rewriting it :<

orschiro commented on 2014-04-08 20:40

@beta990

It is quite usable. Start the service and see if it has a perceivable effect:

# systemctl enable zramswap.service

francoism commented on 2014-04-08 20:02

@swiftgeekL what's the status of this package?
Is it usable or something else? I don't get the last comment, so please explain. :P

swiftgeek commented on 2013-12-07 08:43

Ok this script doesn't understand situation when zram is used also for something else… eg. compressed tmpfs … putting rewrite of this script to (im)pure bash in TODO (it doesn't need to be an early service so it doesn't matter so much)

swiftgeek commented on 2013-12-07 08:38

Now both doesn't work for me xD

swiftgeek commented on 2013-12-07 08:35

@gyscos sorry i didn't checked script including reboot.

gyscos commented on 2013-12-07 08:04

Zramctrl doesn't properly use ZRAM_PARM in modprobe :
Line 22:
system("modprobe zram ZRAM_PARM=" cpucount)

ZRAM_PARM is inside the double quotes and doesn't seem to be expanded.

Instead,
system("modprobe zram " ZRAM_PARM "=" cpucount)

worked for me.

swiftgeek commented on 2013-12-06 08:13

I have no idea how to do that on awk :<

melodie commented on 2013-12-04 17:48

>Comment by swiftgeek
> 2013-08-31 17:55
> on linux 3.10 it is num_devices…

If the script once needs 'num_devices' and another time needs 'zram_num_devices', then the script could be changed to something such as:

################

modprobe zram $(modinfo zram | grep -E -o '(num_devices|zram_num_devices)')=$num_cpus

################

as it has been done here (one meant for Debian):
http://meets.free.fr/Downloads/Debian/zramconfig/zram/etc/init.d/zram

Regards,
Mélodie

j00b commented on 2013-08-31 18:09

I'm running 3.0.27 on an ARM machine. I guess I need an update!
Thanks anyway.

swiftgeek commented on 2013-08-31 17:55

on linux 3.10 it is num_devices…

j00b commented on 2013-08-31 17:50

I was getting the error: "zram: Unkown parameter 'num_devices'" when starting the service.

Turns out that the parameter for the the zram module is 'zram_num_devices' instead of 'num_devices'.

swiftgeek commented on 2013-07-09 09:52

You can set it in service.d file eg.
/etc/systemd/system/zramswap.service.d/size.conf

[Service]
Environment="ZRAM_SIZE=25"


25 is 25% of total RAM

swiftgeek commented on 2013-07-09 09:51

You can set it in service.d file eg.
/etc/systemd/system/zramswap.service.d/size.conf

[Service]
Environment="ZRAM_SIZE=25"

eworm commented on 2013-07-09 09:36

What is the environment variable ZRAM_SIZE good for? At the moment I can not set it at all, no? I removed it from my script and altered the script a bit. Size of zram devices now is about half of physical RAM:

https://gist.github.com/5956013

swiftgeek commented on 2013-06-03 11:43

TODO: Introduce means to configure it (eg. for my system it has to be 50% of RAM or less, otherwise real swapping action fails). Probably via ENV (so config would be in /etc/systemd/system/zramswap.d/)

karol_007 commented on 2013-06-02 21:09

@mmm
This AUR package doesn't compile anything, the two files it provides are human readable.
The code lives in the linux kernel https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/staging/zram
(zram is still in the staging branch)

I think the links mentioned in the Wikipedia are nice, but obviously you can search the Wikipedia or the Arch wiki by yourself.

If the kernel has zram support:
$ zgrep -i zram /proc/config.gz | grep -v "#"
CONFIG_ZRAM=m
(here, it's not compiled in, but used as a module)
you only need this tiny AUR package to make it work.

mmm commented on 2013-06-02 20:31

is there an upstream for this program, or who is developing it? Link to wiki is not so reassuring :)

karol_007 commented on 2013-06-02 01:57

Please update the Maintainer / Contributor part of the PKGBUILD :-)

ifaigios commented on 2013-05-28 13:23

I no longer use this package so I am orphaning it.

lybin commented on 2013-05-28 11:08

https://www.archlinux.org/todo/

Remove old initscipts rc.d files

The time since initscipts became unsupported is sufficient that everyone should have transitioned and these files should be removed. Leaving them in packages appears to be causing some confusion among our users.

Anonymous comment on 2013-05-19 16:57

It does not work in the Raspberry Pi because in the script zramctrl awk counts the lines containing the word 'processor' in /proc/cpuinfo but the for the Pi this file has a different format than in the x86 systems. The easiest solution is to do an ignore case comparison something like:

FILENAME == "/proc/cpuinfo" && ($1 == "processor" || $1 == "Processor") {

But I don't know what would happen if at some point we have multicore ARMs. For a more robust solution I'd would inspect /sys/devices/system/cpu/cpu[0-9]* Probably the safest is to rely on the current method and only if it fails use the new approach.
See in pastebin http://pastebin.com/2ydYbwU5

jskier commented on 2013-01-13 17:59

It does proclaim to have the same amount of swap space as there is RAM on my desktop (I never see the swap utilized), however it is not reserving physical memory unless paging is occurring. Since the swap is compressed, this should not equal all of the physical memory- however it will allocate physical memory of what (if any) is available when the swap is called. So if you only have .5 ~ 2 gigs of RAM being used up anyway, you basically run out of available memory and paging which will either crash or throw an application error from a lack of available memory and page space.

Anonymous comment on 2013-01-13 16:35

felixonmars: I wan't talking about that, I was talking about hitting the limit on the zram devices. Since they are in memory anyway, they are not true swap devices; suppose you swapped 2 GB of pages to a 2 GB swap device that is on 2 GB of physical memory. If the pages swapeed to zram are not easily compressible, it would mean that most of your physical memory is tied up in swap. I imagine this would trigger some pretty nasty out of memory situations. I'm not an expert on these matters either, but it seems dangerous to me to make that situation possible unless there's reason to believe that the scenario I described should never happen.

felixonmars commented on 2013-01-12 13:24

@loonyphoenix
Last time I got a problem in compcache(zram) was because of bigger compressed data (than original data) so the zram got crazy when running out of memory.

Within my understanding, they already fixed it by adding an "if" to ignore compressing when compressed data got even bigger than the trunk it could fit in. Yes this would still keep some memory chunk got bigger than they were, but prevent any fault that related to this from happening.

Please do correct me if I got the upstream idea wrong, as I am not at all familiar with this, either: )

Anonymous comment on 2013-01-12 13:14

Hey, I've got a question. Isn't it dangerous to set the size of the swap to be equal to the physical memory size? What if you fill it with poorly compressible data (I see no reason why memory data should always be compressible) - then you've got practically no memory at all.

jskier commented on 2012-12-10 13:11

It seems pretty unstable. Tried this on my bootable thumb drive and it crashes a lot (no good for a btrfs compress USB stick). Desktop works fine but isn't really needed for that, I never need swap with the RAM I have nor do any applications I run use it.

comcache isn't being maintained in AUR, other than code itself, functionality-wise I don't think there is much of a difference.

mmm commented on 2012-11-14 15:58

please add systemd support

mmm commented on 2012-11-14 15:53

as reported before, I even started to get kernel freezes now, so I had to stop using zramswap for a while. Is the problem still pervail?

Btw, what is difference between zramswap vs comcache?
Thanks,

melodie commented on 2012-11-13 19:20

Hello,

Thanks for this script.

I have two wishes. I would like you guys to point to the real upstream link, which is at the place of the dev of this kernel module:
http://code.google.com/p/compcache

The other wish I have would be for a configuration file to go along with this PKGBUILD : indeed, I would like to have a simple (kiss) way to choose how many block devices I want and what %age of my available ram I want it to be. I have been used to have the values recommended by the dev of the program : 1 block device and 25% of the available RAM, which fits my ordinary hardware (I have some starting from 512 MB ram to 4 GB ram, and several with 1 GB ram).

The first time I have installed zramswap on this one machine which has a brand new install of Arch where systemd is at work, after I installed zramswap my machine hang with a kernel panic, which is the first time it happened since I started using zram, several years ago (when the package name was compcache).

I have no idea how that must be set up to be able to work either with initscripts or with systemd, but I hope having a configuration file in both cases could be possible.

Cheers,
Mélodie

melodie commented on 2012-11-13 19:18

Hello,

Thanks for this script.

I have two wishes. I would like you guys to point to the real upstream link, which is at the place of the dev of this kernel module:
http://code.google.com/p/compcache

The other wish I have would be for a configuration file to go along with this PKGBUILD : indeed, I would like to have a simple (kiss) way to choose how many block devices I want and what %age of my available ram I want it to be. I have been used to have the values recommended by the dev of the program : 1 block device and 25% of the available RAM, which fits my ordinary hardware (I have some starting from 512 MB ram to 4 GB ram, and several with 1 GB ram).

The first time I have installed zramswap on this one machine which has a brand new install of Arch where systemd is at work, after I installed zramswap my machine hang with a kernel panic, which is the first time it happeded since I started useing zram, several years ago (when the package name was compcache).

I have no idea how that must be set up to be able to work either with initscripts or with systemd, but I hope having a configuration file in both cases could be possible.

Cheers,
Mélodie


Siot commented on 2012-10-21 09:11

https://bbs.archlinux.org/viewtopic.php?pid=1178757#p1178757

And an answer

https://bbs.archlinux.org/viewtopic.php?pid=1178820#p1178820

Jristz commented on 2012-10-21 07:50

as far I know systemd-arch-units now only have zramswap service as the only archive in it

leo_rockway commented on 2012-10-14 22:20

This seems related: https://code.google.com/p/compcache/issues/detail?id=102

leo_rockway commented on 2012-10-14 22:04

I get the same errors mmm mentioned. I'm also on Linux from testing (3.6.2 right now, but I noticed this was happening on previous 3.6.x).

mmm commented on 2012-10-07 07:14

Hi, with the latest kernel from testing (3.6), I keep getting a lot of these errors:

[ 3273.022920] zram: Error allocating memory for compressed page: 247029, size=4113
[ 3273.022935] Write-error on swap-device (253:0:1976232)

Any idea? Thanks in advance, Mark

ifaigios commented on 2012-10-01 19:31

Yes, it is needed if somebody wants an automated script to set up zram devices on boot.

Svenstaro commented on 2012-10-01 05:04

Do you even need this package anymore with systemd?

dront78 commented on 2012-09-28 14:55

It's good package to include mainstream

ifaigios commented on 2012-09-24 18:01

You can now remove systemd-arch-units, as systemd-arch-units-20120915-2 contains only the two files provided by this package.

swiftgeek commented on 2012-09-22 18:25

/usr/lib/systemd/scripts/zramctrl is owned by systemd-arch-units 20120704-5
You could change its name at least or put systemd-arch-units in dependencies

swiftgeek commented on 2012-09-22 18:24

/usr/lib/systemd/scripts/zramctrl is owned by systemd-arch-units 20120704-5
You could change it's name at least or put systemd-arch-units in dependencies

swiftgeek commented on 2012-09-22 18:23

/usr/lib/systemd/scripts/zramctrl is owned by systemd-arch-units 20120704-5

swiftgeek commented on 2012-09-22 18:22

/usr/lib/systemd/scripts/zramctrl jest własnością systemd-arch-units 20120704-5

ifaigios commented on 2012-09-22 13:54

I am taking over maintainership of this package. Changes:

- Added systemd service file from package systemd-arch-units
- Now both the service file and the rc.d script use the same awk script to initialize zram devices
- Fixed issue with wrong parameter being used in modprobe (num_devices is the correct parameter as of linux-3.5.4)
- Bumped version to 1

linuxJay commented on 2012-09-20 18:14

zram: `8' invalid for parameter `zram_num_devices'

Deciare commented on 2012-09-20 11:58

Sorry, there's too much real-world stuff I have to worry about right now. Someone else can take this package.

dront78 commented on 2012-09-20 05:10

I think systemd is better choice

ifaigios commented on 2012-09-18 18:37

Please provide the respective systemd service file too (now it is provided by the package systemd-arch-units, which is being dismantled)

dront78 commented on 2012-08-31 09:59

you can use
modinfo zram | grep -E -o '(num_devices|zram_num_devices)'
to detect parameter supported by a kernel and use /dev/null instead of /tmp/zramswap-$$.log

Deciare commented on 2012-06-21 12:28

I can't reproduce the problems people have been having with zram_num_devices, so I'm not sure what to recommend there. This command will tell you how much RAM is currently being compressed on which device:

cat /proc/swaps

I think there used to be more detailed stats somewhere, but I don't remember where that was now.

ismaelvc commented on 2012-06-21 05:02

I just installed it today and I'm also getting the zram_num_devices message, arch fully updted, what should I do? Also how do I get to know how much ram is getting compresed, thanks a lot in advance!

Deciare commented on 2012-06-15 17:20

Yes, and the script accounts for both zram_num_devices and num_devices. (It was named num_devices in 3.2 as well.)

dront78 commented on 2012-06-15 17:19

downloaded today
they just rename to num_devices with 3.4.2

Deciare commented on 2012-06-15 14:11

If you're using the version of the script from 2012-05-19 or later, it should already be working.

dront78 commented on 2012-06-15 11:38

[ 17.395311] zram: Unknown parameter `zram_num_devices'
with latest from stable 3.4.2

linuxJay commented on 2012-06-13 23:07

great. thanks

Deciare commented on 2012-06-13 22:31

That's working as intended. zram may compress up to all available memory as needed, so all 16 GB may be compressed if you have a dire memory shortage. Any memory that is not currently compressed (i.e. outside of swap) remains available as regular uncompressed RAM with no performance penalty.

linuxJay commented on 2012-06-13 22:07

the daemon uses all 16GB of my ram as zramswap. any ideas why? do you need any info?

skydrome commented on 2012-06-04 23:05

use zramswap
https://aur.archlinux.org/packages.php?ID=52958

swiftgeek commented on 2012-06-04 11:02

Another quietly orphaned package :(

Nierro commented on 2012-06-01 17:37

Any .service file for systemd?

swiftgeek commented on 2012-05-28 12:04

Any chance for systemd service?

Rulatir commented on 2012-05-20 17:57

Add dependency on bc (zram_stats script uses it).

Deciare commented on 2012-05-19 17:51

Good call, thank you. Package updated.

deimos commented on 2012-05-19 17:31

The script mistakenly finds multiple processors on my single processor laptop, because "grep processor /proc/cpuinfo"
returns:

processor : 0
model name : Intel(R) Pentium(R) M processor 1.60GHz

I changed "grep -c processor /proc/cpuinfo" to "grep -c ^processor /proc/cpuinfo" in /etc/rc.d/zramswap, so it is only matching for "processor" at the beginning of a line.

Deciare commented on 2012-05-03 18:35

This package works with LTS. You can confirm that by running:

cat /proc/swaps

Error messages you may see at start-up are a result of a change in module parameters in kernel 3.2, and can be safely ignored.

kiodo1981 commented on 2012-05-03 18:23

I use LTS kernel but zram doesn't work.

Deciare commented on 2012-05-03 16:49

I upgraded to linux-3.3.4-2 this morning, and zram is working for me. I don't use zcache, but modinfo is showing that as available too.

ajs124 commented on 2012-05-03 10:37

looks like zram (and zcache) aren't in the stock arch kernel anymore… does anybody know why?

xyproto commented on 2012-02-21 16:44

This package worked for me when compcache didn't, so I like this package better.

Deciare commented on 2012-02-16 18:08

Oh! I sort of didn't know a compcache package also existed. zram is the successor to compcache (a.k.a. ramzswap), so zram does obsolete compcache.

However, the compcache AUR package has been updated to use zram. It seems that the compcache package can be configured to work the same way as this one, but the default behaviour is different. Specifically:

- This package creates a number of zram devices equal to the number of CPUs on the system.
- The compcache package creates up to 4 zram devices, defaulting to 1.

- This package creates a number of zram devices whose total size is equal to the amount of installed RAM on the system.
- The compcache package defaults to using 25% of installed RAM per zram device.

The compcache package's behaviour is configurable; this one is not. That's likely because we followed different directions in creating these packages. I suppose I could make this one configurable, if that would help...?

xyproto commented on 2012-02-16 15:57

Great package. :) Does it obsolete compcache? (https://aur.archlinux.org/packages.php?ID=40063)

Deciare commented on 2012-02-14 17:36

The error message you are seeing is from trying to set the zram_num_devices parameter (for kernel 3.2) before trying the older num_devices parameter. If you check swap space with:

cat /proc/swaps

You will see that zram devices are still present and enabled.

dront78 commented on 2012-02-14 07:33

there is error while loading kernel lts

ZauberParacelsus commented on 2012-02-13 22:39

nvm, I fixed the problem by rebooting.

ZauberParacelsus commented on 2012-02-13 22:19

I think this package may need to be updated for the kernel again, or something.

libkmod: index_mm_open: No such file or directory
libkmod: kmod_search_moddep: could not open moddep file '/lib/modules/3.2.4-1-ck/modules.dep.bin'
libkmod: index_mm_open: No such file or directory
libkmod: kmod_search_moddep: could not open moddep file '/lib/modules/3.2.4-1-ck/modules.dep.bin'
/etc/rc.d/zramswap: line 26: /sys/block/zram0/disksize: No such file or directory
/etc/rc.d/zramswap: line 26: /sys/block/zram1/disksize: No such file or directory
/etc/rc.d/zramswap: line 26: /sys/block/zram2/disksize: No such file or directory
/etc/rc.d/zramswap: line 26: /sys/block/zram3/disksize: No such file or directory
/dev/zram0: No such file or directory
/dev/zram1: No such file or directory
/dev/zram2: No such file or directory
/dev/zram3: No such file or directory
swapon: /dev/zram0: stat failed: No such file or directory
swapon: /dev/zram1: stat failed: No such file or directory
swapon: /dev/zram2: stat failed: No such file or directory
swapon: /dev/zram3: stat failed: No such file or directory
[DONE]

cbowman57 commented on 2012-01-21 13:52

Thanks for adopting it Deciare.

Deciare commented on 2012-01-19 18:02

Adopted and updated to support kernel 3.2.

Svenstaro commented on 2012-01-15 15:58

Feel free to take the package and fix it. I don't use it anymore. It still works for normal usage.

cbowman57 commented on 2012-01-12 18:59

If you bounce back & forth between the 3.1 & 3.2 kernels you might like to modify your /etc/rc.d/zramswap file.

modprobe zram zram_num_devices=$num_cpus
[[ "zram_num_devices" < 1 ]] || modprobe zram num_devices=$num_cpus << new entry

It's probably not perfectly correct but it works.

Anonymous comment on 2012-01-10 11:30

"On July 20th 2011, the zram driver in the linux 3.1 staging area was modified to use zram_num_devices as modprobe parameter - so if you use a recent kernel, update your init scripts!"
http://code.google.com/p/compcache/wiki/Scalability#Details

kiodo1981 commented on 2012-01-07 12:51

Problem with kernel 3.2 CK

mmm commented on 2012-01-06 11:14

x0b1t's advice fixes it, confirm.

but i still get complaint:
sudo /etc/rc.d/compcache start
:: Starting Compcache [BUSY]
FATAL: Module lzo_compress not found.
FATAL: Module lzo_decompress not found.
[DONE]
..using standart arch kernel, compcache seems to work anyway though

Anonymous comment on 2012-01-05 20:46

after update to linux 3.2 (from testing) - need make some changes.
params for zram-module were changed. num_devices -> zram_num_devices

edit /etc/rc.d/compcache.
command for module initilization looks like now as :
modprobe zram zram_num_devices=$DEVICES_COUNT >> $LOG_FILE 2>&1

Decepteiskon commented on 2011-12-13 19:16

Yep, a reboot and a yaourt -S compcache made all.

mortzu commented on 2011-12-13 16:04

So it works?

Decepteiskon commented on 2011-12-13 15:51

Oops, i updated the kernel earlier and i haven't rebooted yet, i should use yaourt -Sf next boot.

Decepteiskon commented on 2011-12-13 15:50

After the update from version 234-1 to 20111213-1 i've got this error:
You need to have compcache listed in deamons in /etc/rc.conf to have it started at boot, like:
DAEMONS=(aaaa bbbb compcache)
To start it in background put there @compcache...

You can (should) modify the size of virtual swap disk in configuration file: /etc/conf.d/compcache. New version of config file is saved as compcache.pacnew

Also note, it is HIGHLY RECOMMENDED to have your kernel patched to provide all functionality, see homepage or readme file to learn more....
Or you can check out ZEN kernel (should allready be patched) from aur.

Initscript outputs are redirected to /var/log/compcache.log

WARNING: Couldn't open directory /lib/modules/3.1.4-1-ARCH: No such file or directory
FATAL: Could not open /lib/modules/3.1.4-1-ARCH/modules.dep.temp for writing: No such file or directory
errore: l'esecuzione del comando non è riuscita correttamente

...but i think that is installed.

Svenstaro commented on 2011-12-07 16:45

Can't reproduce with core kernel.

Nierro commented on 2011-12-07 16:44

me too with kernel 3.1.4 on netbook, and with netbook-kernel too...

skydrome commented on 2011-12-04 19:35

anyone have this problem on the linux-mainline kernel?
:: Enabling zram-based swap [BUSY]
FATAL: Error inserting zram (/lib/modules/3.2.0-1-mainline/kernel/drivers/staging/zram/zram.ko.gz): Unknown symbol in module, or unknown parameter (see dmesg)
/etc/rc.d/zramswap: line 26: /sys/block/zram0/disksize: No such file or directory
/etc/rc.d/zramswap: line 26: /sys/block/zram1/disksize: No such file or directory
/dev/zram0: No such file or directory
/dev/zram1: No such file or directory
swapon: /dev/zram0: stat failed: No such file or directory
swapon: /dev/zram1: stat failed: No such file or directory

Anonymous comment on 2011-11-17 14:10

The current PKGBUILD does not work with the latest pacman v4.
To fix can you please change:
install=(${pkgname}.install)
to
install=${pkgname}.install

Thanks

blackout24 commented on 2011-11-14 22:04

Thank you for contributing to the AUR!

kiodo1981 commented on 2011-11-03 21:08

I have not enabled the SWAP, can I exploit the potential of this program without it?

Anonymous comment on 2011-10-10 01:15

I agree, thanks for this!

Svenstaro commented on 2011-10-09 13:21

Of course.

shadowed87 commented on 2011-10-09 10:03

thank you for this package!!

Huulivoide commented on 2011-07-24 10:45

Please disable the building of the kernel module
as zram is alredy in the kernel tree, and build
by default in arch.

anish commented on 2011-06-22 22:11

on the other hand, /etc/conf.d/compcache ends up with 755, when it should be a 644

anish commented on 2011-06-22 22:06

The line "install -Dm 744 $startdir/compcache.init $pkgdir/etc/rc.d/compcache" is wrong. All files in /etc/rc.d have 755 persmissions, not 744

Anonymous comment on 2011-04-17 23:50

Turns out my previous comment contained error. The matching part should be:

grep -o '/dev/zram[0-9]*' /proc/swaps

So the whole line reads:
for DVC in `grep -o '/dev/zram[0-9]*' /proc/swaps`; do

Additionally the fix for SIZE will be something like this:

$(echo $(($SIZE*1024/$DEVICES_COUNT)) > /sys/block/zram$(($i-1))/disksize) >> $LOG_FILE 2>&1

Anonymous comment on 2011-04-17 23:43

I found two problems with this package. Both concerns compcache.init file.

1) Stopping compcache causes all swap devices to stop. Instead we should only disable zram devices. So it should be something like this (tested & working):

stop)
stat_busy "Stopping $DESC "

for DVC in `grep -o /dev/zram* /proc/swaps`; do
echo "swapoff $DVC" >> $LOG_FILE
swapoff $DVC >> $LOG_FILE 2>&1
echo 1 > /sys/block/`basename $DVC`/reset
done

2) SIZE doesn't take DEVICES_COUNT into account. Therefore with default size of 25% with devices count = 4 it suddendly take whole ram... which isn't good. I think the best course of action here is to divide SIZE by DEVICE_COUNT.

Anonymous comment on 2011-03-06 14:00

it would be good to include sub-projects/scripts/zram_stats to /usr/bin in the package
it is a helper script which shows statistics, as mentioned in the README

mortzu commented on 2011-02-13 16:20

fixed. sorry for that

hydro commented on 2011-02-13 13:28

Please take a look at compcache.init, default size of RAM is not computed correctly (25% = 1/4).

mortzu commented on 2011-01-23 21:14

it runs with 2.6.37

cotton commented on 2011-01-19 13:22

Anyone got compcache working with kernel26-2.6.37ck (or even kernel26-2.6.37)?
Or has it been incorporated into the kernel yet?

Rulatir commented on 2010-12-20 07:47

The only stable compcache I have ever had was the original 0.6.2 on the last kernel that supported it, right before the mainline adoption fiasco started. Since then EVERY compcache/ramzswap/zram build I've ever tried with ANY kernel suffers from the same symptom: running programs start crashing out of the blue when large amounts of data are swapped back in from the compressed swap. Completely unusable.

mortzu commented on 2010-12-01 12:03

updated. thx

Anonymous comment on 2010-11-30 18:48

Here is the Error Message that i receive when i try to install it. I have removed and then reinstall and still have this message

http://pastebin.com/b9GSZyjV

mortzu commented on 2010-10-09 07:45

changed.

Anonymous comment on 2010-10-08 22:30

The script "/etc/rc.d/compcache can not set the size of /dev/zram
I managed to fix it by changing this line
(line 51)
[[ -n $SIZE ]] && echo $(($SIZE*1024)) > /sys/block/zram$(($i-1))/disksize >> $LOG_FILE 2>&1
by
[[ -n $SIZE ]] && $(echo $(($SIZE*1024)) > /sys/block/zram$(($i-1))/disksize) >> $LOG_FILE 2>&1

gaougalos commented on 2010-09-18 23:21

==> Starting build()...
/home/christos/mountPoint/packaging/compcache/PKGBUILD: line 22: cd: /home/christos/mountPoint/packaging/compcache/src/compcache: No such file or directory
Aborting...

Anonymous comment on 2010-09-09 03:06

Maybe add mercurial to makedepends?

mortzu commented on 2010-08-23 22:01

i want to provide a script to rebuild the module like virtualbox do

korin43 commented on 2010-08-23 19:13

This is way more complicated as an AUR package since it can only be built on the currently running kernel, so a kernel update now consists of:
1. Remove compcache
2. Update kernel
3. Reboot
4. Build and install compcache

Chadi commented on 2010-08-21 15:34

Thanks for the package !
Maybe add kernel26-headers and mercurial as build dependencies?