Jump to content

[DEPRECATED] zRAM in Armbian Stretch (mainline 4.14.yy)


Recommended Posts

(disclaimer) No itention to make a Frankendebian (https://wiki.debian.org/DontBreakDebian) but ubuntu package "zram-config" works perfectly.

I tested it for two weeks in a: Orange PI Zero 512MB Armbian Stretch 5.40 4.14.18, Orange PI PC2 Armbian Stretch 5.40 4.14.18, AMD Sempron microserver Debian Stretch 9.4 4.9.0-6-amd64.

 

A short tutorial:

 

1. Download zram-config package (it's a universal package, it does not matter the architecture in use)

wget http://de.archive.ubuntu.com/ubuntu/pool/universe/z/zram-config/zram-config_0.5_all.deb

 

2. Install it

sudo dpkg -i zram-config_0.5_all.deb

 

3. Remove the installer

rm zram-config_0.5_all.deb

 

4. Check vm.swappiness

cat /proc/sys/vm/swappiness

(must be 60, default)

 

5. If not (i.e. "cat /proc/sys/vm/swappiness" return "1" ) change it to "60"

sudo nano /etc/sysctl.conf

and add "vm.swappiness=60" at the end of file

... and reboot

 

6. check zRAM service

sudo zramctl


NAME       ALGORITHM DISKSIZE  DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo         437,8M  5,2M  1,4M  1,9M       2 [SWAP]
/dev/zram1 lzo         437,8M  5,2M  1,4M  1,9M       2 [SWAP]

 

7. (optional) change lzo compression to lz4

sudo nano /usr/bin/init-zram-swapping

 

# initialize the devices
for i in $(seq ${NRDEVICES}); do
  DEVNUMBER=$((i - 1))
  echo $mem > /sys/block/zram${DEVNUMBER}/disksize
  mkswap /dev/zram${DEVNUMBER}
  swapon -p 5 /dev/zram${DEVNUMBER}
done

 

to...

 

# initialize the devices
for i in $(seq ${NRDEVICES}); do
  DEVNUMBER=$((i - 1))
  echo lz4 > /sys/block/zram${DEVNUMBER}/comp_algorithm
  echo $mem > /sys/block/zram${DEVNUMBER}/disksize
  mkswap /dev/zram${DEVNUMBER}
  swapon -p 5 /dev/zram${DEVNUMBER}
done

 

8. restart the service

sudo systemctl restart zram-config.service

 

9. check new compression algorithm

sudo zramctl


NAME       ALGORITHM DISKSIZE  DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lz4         437,8M  5,2M  1,4M  1,9M       2 [SWAP]
/dev/zram1 lz4         437,8M  5,2M  1,4M  1,9M       2 [SWAP]

 

10. check the zRAM priority over file swap

cat /proc/swaps

 

zRAM devices must be at priority "5", swap file at "-1" or "-2"

 

11. finish

:-)

 

 

 

Link to comment
Share on other sites

On 6/5/2018 at 11:19 AM, Moklev said:

ubuntu package "zram-config" works perfectly. I tested it for two weeks

 

Not only you tested it but thousands of OpenMediaVault users (the majority on the Raspberry Pi) since I did exactly the same in our OMV images for ARM boards.

 

But this is not the recommended way any more, lz4 for whatever reasons performs not greater than lzo but it would be great if you can join testing efforts. :)

 

Link to comment
Share on other sites

10 minutes ago, ag123 said:

i tried the above

 

Wrong way since we implemented an own zram-control mechanism in the meantime already available in nightlies and supposed to be rolled out with next major update.

 

For anyone coming across this: do NOT follow the above recipe, it's deprecated in Armbian and causes more harm than any good.

 

@Igor: IMO we need to make the amount of zram configurable. Currently it's set as 'half of available RAM' in line 35 of the initialization routine. But since updates will overwrite this users who want to benefit from massive zram overcommitment (since it just works brilliant) are forced to edit this script over and over again.

 

I propose to define the amount used as $ZRAM_PERCENTAGE that defaults to 50 and can be defined in a yet not created /etc/defaults/armbian-zram-config file. Any opinions?

Link to comment
Share on other sites

ok no worries, will try the nighly way as well, it would seem that stock debian stretch currently is somewhat behind in the mainline kernel updates as well

things that replace the old fex seemed more advanced forwards in the more recent mainline kernels e.g. 4.18 and further ^_^

edit: update

ok switched to nightly

$ /sbin/swapon
NAME       TYPE       SIZE USED PRIO
/var/swap  file       128M   0B   -2
/dev/zram1 partition 61.7M   0B    5
/dev/zram2 partition 61.7M   0B    5
/dev/zram3 partition 61.7M   0B    5
/dev/zram4 partition 61.7M   0B    5

$ /sbin/zramctl
NAME       ALGORITHM DISKSIZE  DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0                50M 10.2M  3.4M  3.9M       4 /var/log
/dev/zram1 lz4          61.7M    4K   63B    4K       4 [SWAP]
/dev/zram2 lz4          61.7M    4K   63B    4K       4 [SWAP]
/dev/zram3 lz4          61.7M    4K   63B    4K       4 [SWAP]
/dev/zram4 lz4          61.7M    4K   63B    4K       4 [SWAP]

$ free
              total        used        free      shared  buff/cache   available
Mem:         505152       67752      262872        3368      174528      423004
Swap:        383628           0      383628

$ /sbin/sysctl -A |grep vm.swap

vm.swappiness = 60

$ uname -a
Linux orangepione 4.14.68-sunxi #161 SMP

 

havn't tried anything else yet, running headless over ssh

----------------------------------------------------------------------------
for zram-config in orange-pi one, i'm not really expecting much of it, it has only got 512k of ram to begin with

for the limited ram and if i want to run any kind of desktop etc having swap to 'extend' the available memory is pretty necessary

i think zram probably increase the performance and reduce the chances of hitting swap on flash

but for small memory device swap on flash is still necessary as a backup, i think that's the default setup

------------------------------------------------

switched to dev kernel

$ uname -a
Linux orangepione 4.18.6-sunxi #159 SMP

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines