OpenWrt Forum Archive

Topic: Openwrt with ZRAM !

The content of this topic has been archived on 5 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Openwrt support ZRAM now !
Let's try it.
By default it will automatically use half of system memory as ZRAM.

root@:/# dmesg|grep -i zr
[    1.250000] zram: num_devices not specified. Using default: 1
[    1.250000] zram: Creating 1 devices ...
[   23.660000] Adding 13308k swap on /dev/zram0.  Priority:-1 extents:1 across:13308k SS
root@:/# swapon -s
Filename                                Type            Size    Used    Priority
/dev/zram0                              partition       13308   0       -1
root@:/#

Now, my Linux server, Android mobiles, and openwrt routers also using ZRAM.
smile

Good news !

May we have some explanation ? smile

From wikipedia:
zRam is an experimental (staging) module of the Linux kernel. It was previously called "compcache". zRam increases performance by avoiding paging on disk and instead uses a compressed block device in RAM in which paging takes place until it is necessary to use the swap space on the hard disk drive. Since using RAM is faster than using disks, zRam allows Linux to make more use of RAM when swapping/paging is required, especially on older computers with less RAM installed


So basically it speeds up HDD access, but perhaps more importantly it reduces read/writes to Flash, which IMO has low longevity on linux due to constant r/w access.
You do need RAM to utilize this. How much?
Back to you johan666

Does Openwrt's kernel support ZRAM ? How do you make use of it ?
I guess we must create a device and issue a "swap on" it ?

ps : sorry for my poor english sad

(Last edited by Chickenbox on 8 Jan 2013, 16:58)

ZRAM supported since trunk r35025
no need to create... config....
by default, the system script will do that.

@robthebrew
Utilize !? experimental !?
Are you kidding me ?
Probably you've totally forgot why you use linux, openwrt.....
roll

lolz

hello,
i need help to add zram capability to my openwrt image, but step by steps:
i try to compile attitude-adjustment image for my Pirelli AGA and i need zram because it has limited resources.
if i try latest trunk this one is too heavy for my AGA, so i must compile old 12.09 revision.
so i tried the rev 38795 but when i run 'make menuconfig' i don't find zram in the configuration tools.
what's wrong?

IMHO zram is fully supported in trunk only

there was some support for Atheros in prior trunk versions

I did test in DIR-300A1 / Fon2100 but was not very happy with trunk newer trunk releases (after rel37729)
even with zram. More RAM than 16mb helps a little.

Trunk BB 37729 works fine though without zram on 4/16MB on old hardware Fon / DIR300A1
(build without IPV6 and other goodies you dont need)

Seems the new shiny procd/netifd/ubus and JSON stuff eating alot of RAM/CPU power.
Lets build a new tower of trash with the "old" router hardware ( quite SAD ) for the GLORY of these new implementations
Also never heard about specific heed this will come in such a way.

Communication in not the strongest part of the developers, system documentation neither.
I do wonder where the treashure of information is hidden though.
Welcome to wade through Trak - mailinglist - sourcecode to find a peace now and then.

https://dev.openwrt.org/browser/trunk/p … ?rev=35028

http://patchwork.openwrt.org/patch/1609/

search for zram Bastian Bittdorf


You may try to build BB trunk @37729 ( or around ) with IPV6 disabled and other goodies (ppp) which you wouldnt need.

Gives you some RAM headroom to run without zram also

I'm currently looking at which trunk rev they move from init to procd for my batman-adv builds

regards
3zl

3zl wrote:

IMHO zram is fully supported in trunk only

there was some support for Atheros in prior trunk versions

I did test in DIR-300A1 / Fon2100 but was not very happy with trunk newer trunk releases (after rel37729)
even with zram. More RAM than 16mb helps a little.

Trunk BB 37729 works fine though without zram on 4/16MB on old hardware Fon / DIR300A1
(build without IPV6 and other goodies you dont need)

if I understand well:
- You say that AA don't works fine with 16mb, with or not zram.
- You say also that Barrier-Breaker works better than Attitude-Adjustment on hw with 16mb or less.

Well, I have compiled rev newer than rev38795 (is it BarrierBreaker?) and I have tried it on my AGA but it reboot every time, I think due saturation Ram.

3zl wrote:

Communication in not the strongest part of the developers, system documentation neither.
I do wonder where the treashure of information is hidden though.
Welcome to wade through Trak - mailinglist - sourcecode to find a peace now and then.

https://dev.openwrt.org/browser/trunk/p … ?rev=35028

http://patchwork.openwrt.org/patch/1609/

search for zram Bastian Bittdorf

I know that links but I don't know how I could use them....

3zl wrote:

You may try to build BB trunk @37729 ( or around ) with IPV6 disabled and other goodies (ppp) which you wouldnt need.

Gives you some RAM headroom to run without zram also
regards
3zl

I'll try again to build BB trunk.
Please help me: which goodies can disabled if I need to use AGA like 'sta' or 'repeater'?

Thank a lot

Your Pirelli AGA is a bcm63xx router, isn't it?, if you want to use wl drivers currently the best option is to use AA, among other things that may fail in trunk revisions.

You can use zram in AA 12.09. Since zram is a kernel thing already present in 3.3 kernels, just build openwrt with zram enabled in the kernel itself:

make kernel_menuconfig

Search for zram and enable it.

Then once the firmware is built and flashed, you can activate it, example 5MB:

echo $((5*1024*1024)) > /sys/block/zram0/disksize
mkswap /dev/zram0
swapon /dev/zram0

You can add these comands to rc.local, or make an init script to activate it earlier.



more info about zram at:
http://lxr.free-electrons.com/source/dr … .txt?v=3.3

yes, AGA is a bcm63xx router.

robthebrew wrote:

From wikipedia:
zRam is an experimental (staging) module of the Linux kernel. It was previously called "compcache". zRam increases performance by avoiding paging on disk and instead uses a compressed block device in RAM in which paging takes place until it is necessary to use the swap space on the hard disk drive. Since using RAM is faster than using disks, zRam allows Linux to make more use of RAM when swapping/paging is required, especially on older computers with less RAM installed

That's true. However, doesn't any compression/decompression use up CPU cycles?

danitool wrote:

You can use zram in AA 12.09. Since zram is a kernel thing already present in 3.3 kernels, just build openwrt with zram enabled in the kernel itself:

make kernel_menuconfig

Search for zram and enable it.

please tell me what exactly does: 'make kernel_menuconfig' .

Now if i type

svn co svn://svn.openwrt.org/openwrt/branches/attitude_adjustment

it download rev 40423. is it correct?

(Last edited by gem1978 on 8 Apr 2014, 17:44)

<That's true. However, doesn't any compression/decompression use up CPU cycles?>

true..so practically its stops the router from beeing reset by watchdog/low memory
but takes quite some efford/ compressing/decompressing which lags responsiveness

there is some adjustment you can make with "swappiness" a.s.o but practically not much use in old Fon2100/DIR300A1

I wasnt happy with the solution then and rather went for smaller build with trunk around 37729 (old init instead of procd..)
Speaking of atheros branch though.

Implementation of zram depends on target/kernel & release

regards
3zl

danitool wrote:

You can use zram in AA 12.09. Since zram is a kernel thing already present in 3.3 kernels, just build openwrt with zram enabled in the kernel itself:

make kernel_menuconfig

Search for zram and enable it.

I don't understand.... in order:
- 'make kernel_menuconfig' 
- enable zram
- 'make'
After that, I need to do:
- 'make menuconfig'
- search and enable my favorites options
- apply patch for the AGA
- 'make'

It's right?

No

1- "make menuconfig" and select your target
2- "make kernel_menuconfig" and enable zram
3- make the modifications to the kernel at the build dir for AGA, and at the target dir if you need it.
4- "make"

No idea about the support for the AGA router, if you have a patch for the buildtree, then apply it before step 2.

yes, aga router needs a patch.
Here wiki.openwrt.org/toh/pirelli/aga you can find more about it.

I hope the patch works again...it's for the rev 33981. I think i will must to adapt it to the last stable rev.

danitool wrote:

....
2- "make kernel_menuconfig" and enable zram
....

i don't find zram in any place....
where should I look?

EDIT
i found it:

main menu ->
device drivers ->
Staging drivers ->
"Compressed RAM block device support"

(Last edited by gem1978 on 13 Apr 2014, 23:31)

danitool wrote:

Then once the firmware is built and flashed, you can activate it, example 5MB:

echo $((5*1024*1024)) > /sys/block/zram0/disksize
mkswap /dev/zram0
swapon /dev/zram0

You can add these comands to rc.local, or make an init script to activate it earlier.

if i want to build  a firmware with zram already active?

then add it to

package/base-files/files/etc/rc.local

in your build root

Edit: and don't forget to build it with the package swap-utils

(Last edited by danitool on 14 Apr 2014, 00:01)

what is the difference betwenn yours rc.local and this

echo 100000000 > /sys/block/zram0/disksize
mkswap /dev/zram0
swapon -p 5 /dev/zram0

what does "swapon -p5" ?

EDIT
"-p 5" set priority class.
But priority compared to what?

(Last edited by gem1978 on 29 Apr 2014, 14:41)

That's the priority compared to other swap devices.

Thank you.

The discussion might have continued from here.