[Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Post Reply
User avatar
XeoSal
Posts: 925
Joined: Sun Aug 30, 2015 11:21 pm
languages_spoken: English
ODROIDs: C1, C1+, C2 & XU4
Contact:

[Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by XeoSal » Wed Jan 06, 2016 11:20 am

I just wanted to make it easy on folks that are using the official Ubuntu image, this is my zRAM scripts from Odrobian that will let you logically increase your RAM from 1GB up-to 2GB easily with simple commands.
Odrobian-zRAM.png
(36.8 KiB) Downloaded 3415 times
What is ZRAM?
zRam is a code inside kernel working as a module, that once activated, creates RAM based block devices (named /dev/zramX) which act as 4 swap spaces each one is handled by a single core, but are compressed and stored in memory (will never use SD space but only the dedicated RAM), allowing very fast I/O and virtually increasing the amount of memory available before the system starts swapping to the storage swap if available (in case you wish to create an additional swap storage on SD card or USB disks) for heavy multitasking.

So, it's like converting a little CPU power out of each core to a real dedicated memory making use of compression mechanism for the data stored in memory blocks logically increasing the C1's RAM from 1GB up-to 2GB. You can also add about 500MB if you want (it will almost never be used) as additional storage swap on SD card or whatever, you will be amazed of how fast and responsive your C1 can be with this set-up beside the 4 ZRAM (each one is about 512MB in size as a total of 2GB) swaps enabled.

Installation/Removal
Simply, open up a terminal (Ctrl + Alt + T) and do this:

Code: Select all

odroid:$ wget  http://oph.mdrjr.net/odrobian/pool/s805/s/s805-zram/s805-zram_1.0-1_armhf.deb
odroid:$ sudo dpkg -i s805-zram_1.0-1_armhf.deb
This is a Debian package, meaning you can get rid of it anytime you want:

Code: Select all

odroid:$ sudo apt-get purge s805-zram
You can also extract it and watch through its content if you want to learn how it's implemented.

Enable/Disable ZRAM
You can now use 2 commands to control (enable/disable) zRAM module anytime you want:

Code: Select all

Enable ZRAM during boot process (Logical 2GB RAM):
odroid:$ sudo enable-zram

No ZRAM during boot process (Stock 1GB RAM):
odroid:$ sudo disable-zram

(both commands require restarting your device)
You can confirm that you have 2GB of RAM if you run System Monitor or by issuing "free mem" command, in both cases look at the amount of swap memory available:

Code: Select all

odroid:$ free mem

(Total swap should be about 2056560 meaning 2GB)
This is going to make crashes due to running out of memory a history, enjoy guys! :)
Last edited by XeoSal on Tue Feb 23, 2016 5:57 am, edited 1 time in total.

User avatar
odroid
Site Admin
Posts: 29360
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by odroid » Wed Jan 06, 2016 4:49 pm

Thank you for the image.

luxmile
Posts: 33
Joined: Wed Feb 25, 2015 10:52 am
languages_spoken: english
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by luxmile » Wed Jan 06, 2016 5:08 pm

Coool... :)

theBOSS
Posts: 75
Joined: Sat Jan 17, 2015 2:06 am
languages_spoken: spanish, english
ODROIDs: C1
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by theBOSS » Wed Jan 06, 2016 7:29 pm

Thanks for the package but in Ubuntu distro you can install with a simple comand:

Code: Select all

sudo apt-get update && sudo apt-get install -y zram-config
If you need to remove from system

Code: Select all

sudo apt-get remove -y zram-config --purge
The program will start in the next reboot, and for view the the swap status:

Code: Select all

cat /proc/swaps
Best regards!
http://lordpedal.ddns.net... la culminación de un fin es el comienzo de una realidad.

User avatar
XeoSal
Posts: 925
Joined: Sun Aug 30, 2015 11:21 pm
languages_spoken: English
ODROIDs: C1, C1+, C2 & XU4
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by XeoSal » Wed Jan 06, 2016 11:11 pm

theBOSS wrote:Thanks for the package but in Ubuntu distro you can install with a simple comand:

Best regards!
Hey my friend,

Nice to know that Ubuntu has a sample zram implementation for this, although my package is configured specifically for ODROID C1 with 2GB ram, while this one available on Ubuntu repository isn't pre-configured for 2GB RAM (it will give you about 200MB additional logical RAM) which may be hard for new users that want to do this easily (no need to configure anything with my package - and it contains enable/disable options as well). :)

Best Regards!

User avatar
mad_ady
Posts: 5096
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1
Location: Bucharest, Romania
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by mad_ady » Sat Jan 09, 2016 10:44 pm

@XeoSal: Could you tell us how to tweak the zram size? Getting an extra 1G is nice, but I would like to get only 500MB. :)

Edit: After activating it, I guess the parameter FRACTION=240 could be changed, or the init script which enables it for each cpu (tweak the number of cpus). I'm not sure how zram works exactly, but I see it as swap (2G). Does this mean that it starts compressing when it starts running low on RAM, or it uses compression from the start even if there is free ram available?

LiquidAcid
Posts: 1088
Joined: Fri Oct 11, 2013 11:07 pm
languages_spoken: english
ODROIDs: X2
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by LiquidAcid » Sat Jan 09, 2016 11:02 pm

Setting up four block devices is unnecessary, since you can just increase the maximum number of concurrent compression streams.

User avatar
XeoSal
Posts: 925
Joined: Sun Aug 30, 2015 11:21 pm
languages_spoken: English
ODROIDs: C1, C1+, C2 & XU4
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by XeoSal » Sun Jan 10, 2016 3:24 am

mad_ady wrote:@XeoSal: Could you tell us how to tweak the zram size? Getting an extra 1G is nice, but I would like to get only 500MB. :)

Edit: After activating it, I guess the parameter FRACTION=240 could be changed, or the init script which enables it for each cpu (tweak the number of cpus). I'm not sure how zram works exactly, but I see it as swap (2G). Does this mean that it starts compressing when it starts running low on RAM, or it uses compression from the start even if there is free ram available?
Yeah, you can play around with the amount if you change values related to the formula, the simplest way if you want no hassle would be just changing the fraction:

Code: Select all

FRACTION=240 (reducing this value will result in reducing the size of each swap block device as well)
Fraction is a part of this formula:

Code: Select all

SIZE=$(( MEMORY * FRACTION / 100 / CPUS ))
Generally, the kernel will not start swapping/compressing into the ram until it's actually needed, which is very nice for keeping the CPU at its highest performance rate unless you need to take some power from it for your memory needs. Apparently, in my experience, if you keep memory used always higher than 1GB, the zRAM module will keep about 100 ~ 200MB amount of dedicated memory at least already free in case of ODROID C1 (meaning it started compressing the current data stored in memory blocks preventing further size increasing), but when you reach about 1.8GB of swap memory usage then free dedicated memory will start slowly to vanish completely.

The number of zRAM memory block devices is generated automatically according to the number of cores you have in your CPU, meaning each block device is handled by a single core, as a result of this code:

Code: Select all

CPUS=`grep -c processor /proc/cpuinfo` (this command will return value as "4" which is number of cores on ODROID C1)
The total amount of real memory included in the previous formula is determined by this:

Code: Select all

MEMORY=`perl -ne'/^MemTotal:\s+(\d+)/ && print $1*1024;' < /proc/meminfo`

User avatar
mad_ady
Posts: 5096
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1
Location: Bucharest, Romania
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by mad_ady » Sun Jan 10, 2016 4:28 am

Thank you for the clarification!

kvetter
Posts: 14
Joined: Sat Dec 05, 2015 10:41 am
languages_spoken: english
ODROIDs: C1+
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by kvetter » Wed Jan 20, 2016 11:25 am

Thank you THANK YOU

I had looked for about 5 hours on how to get the zram installed/enabled. This took about 5 minutes.
You can also extract it and watch through its content if you want to learn how it's implemented.
Could you explain "extract and watch watch through"? I would have liked very much to have seen what happened.

Thank you
Have a great day

User avatar
XeoSal
Posts: 925
Joined: Sun Aug 30, 2015 11:21 pm
languages_spoken: English
ODROIDs: C1, C1+, C2 & XU4
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by XeoSal » Wed Jan 20, 2016 11:38 am

kvetter wrote:Thank you THANK YOU

I had looked for about 5 hours on how to get the zram installed/enabled. This took about 5 minutes.
You can also extract it and watch through its content if you want to learn how it's implemented.
Could you explain "extract and watch watch through"? I would have liked very much to have seen what happened.

Thank you
Have a great day
Hey my friend,

Extracting debian packages will show the files installed on your system along with their location, you can either extract it from GUI through an archive manager or just use console:

Code: Select all

odroid:$ ar x odroid-zram_1.0-1_armhf.deb
When it's done you should see these files inside the extracted package folder:
  • 1. /etc/init.d/zram
    2. /usr/local/bin/enable-zram
    3. /usr/local/bin/disable-zram
These files should already be present on your system after installation of zram package in the same paths, you might not want to extract it because I already told you about the location of files.

Just take a look into the main script which is "zram" to understand and play with its settings, I have explained more about it on my previous reply, also you can see how its activated on boot using the rc.d on Debian through the "enable-zram" script.

You are welcome. :)

Pitrson
Posts: 53
Joined: Mon Jan 18, 2016 11:16 pm
languages_spoken: english, slovak
ODROIDs: Odroid C1, XU4
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by Pitrson » Fri Jan 22, 2016 7:35 pm

Nice one ...would you please perform some benchmarks to compare with and without zram ? Mainly memory related of course .. 8-)

Thanks!

User avatar
XeoSal
Posts: 925
Joined: Sun Aug 30, 2015 11:21 pm
languages_spoken: English
ODROIDs: C1, C1+, C2 & XU4
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by XeoSal » Mon Jan 25, 2016 2:19 pm

Pitrson wrote:Nice one ...would you please perform some benchmarks to compare with and without zram ? Mainly memory related of course .. 8-)

Thanks!
Hey man,

There is no need for benchmarks here, the zRAM will not improve CPU performance at all, it will mainly make the ODROID C1/+ usable as a main computer, because it will prevent you from running out of RAM which can result into strange behaviors, the worst case is freezing and crashing the whole device, many people reported they had broken system while trying to upgrade the kernel without paying attention to memory usage, they screw up when they for example start browsing the web while the system is getting updated at the same time, that's when the device will freeze, while with zRAM it will not freeze assuring smoother experience as a bonus as well.

As I said before, it will act as a back-up memory which will not be used unless you fill up the dedicated memory free space, meaning it's just an advantage. Technically, it will really increase the real-life performance of ODROID C1 specifically, at some point you will notice the device lagging when multitasking ending with a freeze, with zRAM you get much more smooth experience making memory freezes go bye bye however, zRAM has some "limitations" as explained in previous posts but regarding to my experience there are no disadvantages.

sputnik
Posts: 68
Joined: Tue Aug 11, 2015 9:39 am
languages_spoken: english, some spanish
ODROIDs: C1+
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by sputnik » Tue Feb 02, 2016 12:29 pm

I'd like to add to XeoSal's last post. I've been using zram on my C1+ (using Funtoo) for some time now, using the same parameters XeoSal uses. As you may know in Funtoo/Gentoo ALL updates are compiled from scratch, no binary blobs like Ubuntu, I update daily. I agree that zram can provide smooth results but it's not perfect, I suspect it would be better if we had a newer kernel. The general consensus on the web is that they "worked out all the bugs" by kernel 3.15.
It works great for most compiles and it's easy for me to push Chromium into a memory overload condition (just open more tabs, but even 3 is a risk of freeze!), as long as I don't push Chromium too hard it does improve that too.
But I have two programs that will not compile with zram at all, yet if I disable it they compile fine. They are cmake and poppler. It seems zram is not quite as transparent about bowing out as it should be, at least in this older implimentation. It seems that there just isn't enough ram with zram enabled for those hungry programs to do what they need to do. Funny, because each zram instance is only about 11 or 15k, something like that, when not being used. I doubt 60k is pushing over the limit, so I gotta blame zram.
I've never been able to compile two other programs natively, gcc and boost, I have to use qemu on my x86_64 to do those and it is ____slow. 2 days for gcc last time. But I only learned to disable zram on cmake and poppler recently, so next time gcc and boost are updated that may do the trick. Also I should add that I believe not all programs are compatible with swap when compiling, so it's possible it's not zram's fault.
A side note, I also use distcc for the odroid and with that and zram compiles go almost as quickly as they do for the 64 bit machines.
Summing up, I recommend zram, mostly it's great, but it isn't going to turn your C1 into a 3GB behemoth.

sputnik
Posts: 68
Joined: Tue Aug 11, 2015 9:39 am
languages_spoken: english, some spanish
ODROIDs: C1+
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by sputnik » Sun Feb 14, 2016 3:48 am

I must correct my previous post, it is in error.
It seems long ago when I was experimenting with zram I was also trying out zcache. By chance I noticed a couple of days ago that I still had zcache in my kernel cmdline. I removed it. Last night boost was compiled, I didn't disable the zram and it went just fine. So there was some evil interaction going on with zcache-zram.
So briefly zram is working better than I thought, I'm very pleased with it.

fab
Posts: 212
Joined: Mon Apr 28, 2014 3:51 pm
languages_spoken: english French
ODROIDs: Odroid W + Odroid C0 + Odroid C1 + Odroid C2
Location: France Orleans
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by fab » Tue Feb 23, 2016 12:28 am


User avatar
XeoSal
Posts: 925
Joined: Sun Aug 30, 2015 11:21 pm
languages_spoken: English
ODROIDs: C1, C1+, C2 & XU4
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by XeoSal » Tue Feb 23, 2016 5:24 am

Yeah, I have created a better and more standard one, I will edit on main post now and the new link is: http://oph.mdrjr.net/odrobian/pool/s805 ... _armhf.deb

You can also get this package simply through "apt-get" if you integrate my repository (odroid/s805) branch on Ubuntu, there is an "HOWTO" if you want to learn more.

fab
Posts: 212
Joined: Mon Apr 28, 2014 3:51 pm
languages_spoken: english French
ODROIDs: Odroid W + Odroid C0 + Odroid C1 + Odroid C2
Location: France Orleans
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by fab » Tue Feb 23, 2016 3:21 pm

Many thx!
Fab

petevine
Posts: 132
Joined: Thu Aug 06, 2015 4:41 am
languages_spoken: english
ODROIDs: C1, MXQ PRO+

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by petevine » Fri Mar 25, 2016 10:29 pm

XeoSal wrote: Generally, the kernel will not start swapping/compressing into the ram until it's actually needed
Actually no, ZRAM swap is meant as a fully transparent device, so the most relevant parameter is called swappiness. The default is set to 60 which means the kernel starts swapping quite early once memory gets filled with disk cache. (instead of evicting the cache)

To get the kernel to start swapping as late as possible:

Code: Select all

echo 0 > /proc/sys/vm/swappiness
--
A few packages and other useful stuff for Odroid C1 or ARM64. * PyPy for non-SSE2 CPU's anyone?

fab
Posts: 212
Joined: Mon Apr 28, 2014 3:51 pm
languages_spoken: english French
ODROIDs: Odroid W + Odroid C0 + Odroid C1 + Odroid C2
Location: France Orleans
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by fab » Thu May 12, 2016 10:00 pm

Since the latest kernel update, #XeoSal zam is no longer working. Instead of having 1GB of additionnal RAM, we now have swap.... :( (4 x ZAM partitions of swap). The "free" command now returns "971652", so 1GB instead of 2GB with the previous kernel versions....

Any ideas of what I have to do in the zram_config init script to fix this issue?

vboof
Posts: 1
Joined: Sun Feb 19, 2017 4:45 pm
languages_spoken: english
ODROIDs: C1
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by vboof » Sun Feb 19, 2017 5:19 pm

I tried to install the odroid zram script this morning and I have a similar problem, the swap devices are created but with errors, and swapon cannot use them, or not with the right size.

The same problem occurs with the standard zram-config package which uses less memory per swap file.

Here is what I see in /var/log/syslog for each swap device when it fails:
Feb 19 08:02:01 odroid init-zram-swapping[1875]: mkswap: error: swap area needs to be at least 40 KiB
Feb 19 08:02:01 odroid init-zram-swapping[1875]: swapon: /dev/zram3: read swap header failed

Even when it works, free mem does not always report the sum of the allocated swap files (for example I setup 4*400MB and I get a total of 1200MB).

it feels like when mkswap is called, the memory size to allocate in /sys/block/zram${DEVNUMBER}/disksize is not fully written

I added a sleep 1 between the echo into /sys/block/zram${DEVNUMBER}/disksize and the mkswap and it seems to work (but it does not fell right!)

But it is good enough for now, I still have to check if this solves my problem with chromium memory consumption...

moon.linux
Posts: 1161
Joined: Thu Oct 02, 2014 11:42 pm
languages_spoken: english
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by moon.linux » Tue Feb 21, 2017 9:17 pm

zram should support compression algorithm a like LZ4_COMPRESS or LZ4HC_COMPRESS or LZO_COMPRESS,
and their could be many parameter that could be tuned to enhance the zram feature.

looking into more such configuration and patches to support full zram swap for Odroid C0/C1

Nuems
Posts: 103
Joined: Thu Sep 19, 2013 3:50 am
languages_spoken: english, german, some spanish
ODROIDs: xu, c1
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by Nuems » Sat Feb 25, 2017 9:50 pm

I've got the same impression as vboof: Currently, it doesn't work properly on boot, but running it later on works as expected. Instead of adding "sleep 1" - shouldn't we try to run the script later in the startup process?

Edit:
Here's what I did on Ubuntu 16.04.2:
As XeoSal's solution is based on a classical init script, it's up to systemd to decide when to run it unless it finds a respective softlink in one of the /etc/rc*.d directories. I found the auto-generated softlink in /etc/rc2.d and moved it to /etc/rc5.d. Works so far, ie. zram is created on startup.

User avatar
meveric
Posts: 9600
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by meveric » Sat Feb 25, 2017 10:24 pm

the script from XeoSal is known to have issues. The value of 2GB is way to big and can cause issues.
The init script is has wrong values as you can see with the above issue.
The value of the ZRAM can only be edited in the init-script and not a config file or whatever.
There was an article about this in the ODROID Magazine stating that the way XeoSal uses ZRAM is actually potential dangerous, therefore the script shouldn't be used at all.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

Nuems
Posts: 103
Joined: Thu Sep 19, 2013 3:50 am
languages_spoken: english, german, some spanish
ODROIDs: xu, c1
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by Nuems » Sat Feb 25, 2017 11:59 pm

Good to know. Do you remember which issue the article was in?

User avatar
meveric
Posts: 9600
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by meveric » Sun Feb 26, 2017 9:43 am

Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.

Nuems
Posts: 103
Joined: Thu Sep 19, 2013 3:50 am
languages_spoken: english, german, some spanish
ODROIDs: xu, c1
Contact:

Re: [Release] Logical 2GB RAM on Ubuntu for ODROID C1/C1+

Unread post by Nuems » Tue Feb 28, 2017 4:53 am

Thanks.

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 1 guest