Increasing Ram on your Raspberry Pi with ZRAM
ฝัง
- เผยแพร่เมื่อ 10 ก.ย. 2024
- This is a quick little walk through what I have been doing to my raspberry pi laptop, using conky to display my computer stats, and wbar for doc, also increased the ram by using zram which compresses memory, many devices like chrome os and androids use this same method. thanks for the view!
○○○ LINKS ○○○
Novaspirit Site ► goo.gl/BnQN2v
Github ► goo.gl/cVPCfB
Raspberry Pi 3 ► www.novaspirit....
Novaspirit TV ► novaspirit.com...
○○○ Other Videos ○○○
Raspberry Pi Zero Projector ► novaspirit.com...
Streaming Steam over the internet ► novaspirit.com...
Compiling Source Code ► goo.gl/UObjER
DIY Raspberry Pi Laptop ► novaspirit.com...
Sharing KB & mouse with synergy ► goo.gl/I3Ig7X
Raspberry Pi Zero USB Dongle ► goo.gl/hyOJ6H
Installing Teamviewer on raspberry pi ► goo.gl/Fmz39g
water cooling raspberry pi ► goo.gl/OBAmvr
How i Make youtube videos ► goo.gl/qKsI9s
patreon @ / novaspirittech
Tweet me: @ / novaspirittech
facebook: @ / novaspirittech
Instagram @ / novaspirittech
DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!
Today I learned how to download more RAM.
For once it isn't a lie, lol
Downloud ram is possible !!!
i knew it !!
Ya but you need storage to turn into ram so get a better sd card or graphic card
@@quirkychamp9152 but thats slower than RAM
In 2020 I was able to download rom 😎.
For everyone that thinks this is magically "adding MORE RAM" to your RPI, all it does is it compresses "makes smaller" the stuff that is temporarily stored on the RAM by the CPU. This allows the CPU to put more stuff in RAM as now the space the the other stuff is smaller allowing you to put MORE in the same AMOUNT of RAM. The "side-effect" of this is that compression algorithms are not 100% efficient which means you will have to wait longer when the data on the RAM has to be decompressed then executed by the CPU.
Thanks
Next time on Novaspirit Tech: downloading a GPU
Next time on Novaspirit Tech: downloading a gaming pc
Works really well, totally worth it, if a pi is rich in CPU cycles and low on memory, this is a no brainner, Raspbian and Retropie, Kodi, will work better with this script.
William Rutter will it make Plex transcoding better on the raspberry pi?
@@enochthestud No, transcoding is cpu/gpu dependent.
Thanks! This short video is really helpful: didn't know about htop, conky, and zram. Got them both and with your config file it was no issue to get it running. Thanks again!
OMG thank you my system was SO SLOW i couldn't even run 2 tabs without glitch now i can run 8 tabs FASTER than before with 2 tabs
zram just creates compressed swap on RAM. This makes sense for this use but you're explaining it really badly.
memory isn't "echo'd" into zram. Those echo lines in that script are setting the size of the devices by writing that size to /sys virtual files.
It's also not really giving you an extra 1GB of RAM. I'm guessing the ZRAM devices are allocated dynamically, so they grow as they fill up, so your RAM will reduce as data is swapped out, and the amount of space you gain by swapping it out will really come down to the compressibility of the data.
Extremely well done. I'm gonna give this a try on my kitchen-pi terminal. It's streaming video and doing Amazon Alexa at the same time so this might give it a bit of a "boost" . Thanks for the video. Eric
you got a great channel there ERIC! lets get together sometime and make stuff happen, hope you don't mind if i email you?
Novaspirit Tech Thanks for the kind words. Sure sounds good. Merry Christmas.
email sent =) merry Christmas to you too
not possible it would suffer the optimization or minecraft java and for that matter java itself is horific you could run minecraft c++ so PE or win10 if you got the source code...
To be honest,i love raspi and all.but to 4gb you need an Ryzen microAtx and the full Rig Micro atx...it goest better and tiny as well as maybe the double of pi cases size.
I was planing sell my fx8350 to get one full rig micro atx...but i didnt sold..i keep because i builded less than 1 month before..but it worth the size and money!
one of the fastest and best youtubers on explaining without all BS, top notch!!!
imagine how much time saved, hope you will do some Bitcoin,ethereum, ZEC, Dash CPU mining on a Raspberry pi. Keep posting.
and clustering raspberry pi for better performance on mining
Guys - before making comments - this is a ram compression scheme - it is NOT more RAM - you cannot GET more RAM for the Pi without getting an ultrafine soldering iron out - and I'm not even aware of anyone who has done that successfully. If you want more RAM there are plenty of alternative boards out there with 2GB RAM.
Aww man downlouding ram is still a lie 😢😢😢😢
@ExoPhantomFalcon fuck me from 1 year ago is cringey as fuck
@ExoPhantomFalcon im one of what people ?
Could you make a video to show how to use a usb drive for more ram? For the raspberry pi.
You install your own programs and scripts in /usr/local/bin, not in /usr/bin or in /bin. Those are reserved for Debian to install its own binaries from packages.
if you do it, it could turn out to be a problem later.
You can avoid issues by not creating scripts that are named after other binaries in one's distro's repositories. Also...
Arch > Debian
This is a good point. Changing my setup. I was vaguely suspicious about the path but too excited about the new toy.
I got it working! Figured out to use cursor to select line... got Conky going too and the first thing I noticed video plays without any lag with large display size definitely faster showing the 1Gig swap in Conky but temps up from around 38C to 45C and cpu usage about 50%, stop the video and it drops down to almost normal, was 0% at idle now lowest is about 5%. The trade off seems absolutely worth it considering the almost unwatchable slow buffering of video before, thanks really appreciate your Conky and Zram files and info!
ZRAM will not create an additional GB of RAM, that is a lie, SWAP is a cache space to store temporary data
he explains that at the beginning of the video...
zram compresses swap and stores it in ram.
true
I’m blessed to be alive to see this🙏🙏
I already miss being able to use xz compression as I used to with COMPCACHE. It's slower per operation, but operations are less frequent, and its compression is enough better than the rest that it's overall faster due to even less swapping to a slower device.
Better way to increase the SWAP is edit dphys-swapfile:
Before we can increase our Raspberry Pi’s swap file
**sudo dphys-swapfile swapoff
Modify the swap file configuration file
**sudo nano /etc/dphys-swapfile
Search and modify CONF_SWAPSIZE=100
For example, if we wanted to increase our swap size to 1GB, we would change that line to the following:
**CONF_SWAPSIZE=1024
Next save the file by pressing CTRL + X, followed by Y, then ENTER.
Now restart your device.
**sudo reboot
This why i like the pi, and the community. Exellent !!!!!!!!!!!!!!!!!!!!!!!!!
This nothing great/new even windows can do it and every other os...
Interesting stuff. So how much physical RAM does that swap pool actually take when it's full? How much slower is it? What kind of CPU usage should we expect?
I hope this works like you say it does. Because the Pi's could do with maybe another 2gb. The makers should have a look at upping the ram. I don't think any of us would mind a couple extra bucks for a 2+gb model.
What about overclocking? Wouldn't it be more helpful?
Another efficient way to increase the SWAP is from dphys-swapfile:
$ sudo nano /etc/dphys-swapfile
# For 1GB
CONF_SWAPFILE=1025
# For 2GB
# CONF_SWAPFILE=2050
This Script just stuffed up my SD card I've been running for 6 months and sadly, I was going to back up later today
Sense this is for the raspberry pi 3. Would this work on the raspberry pi 4? I have one of the cm4 compute module 4 and it only haves 1gb. And needing more. Sense I don’t use monitors it’s all headless will this work?
What is that thing you have the desktop not sure if you said carnky or something else either way can't find anything on the Internet for it or anything for it
Need help please... cannot edit script “sudo nano /etc/rc.local”, terminal writes “/usr/bin/zram.sh &” to the beginning before the first “#” at top. How do I insert where you did?
Question, How well will this process work with a Plex Server (using a PI 4 8GB). I'm getting buffering when 2-3 people are using it. Thanks
Bro when you opened the black window I saw my whole eyeball in my reflection..
Looks good.I will have to try it when I can. Thanks.
Great Job hope you feel better
This description is bad. However I loaded Conky and setup zram on my Pi4 today and the speed increase is noticeably faster. Trade off is the CPU is averaging higher load. Playing around with the disk space I notice my swap partition gets larger but does not seem to be used any longer? I have the 2GB model and leave only 256MB for the GPU share. My Pi4 is running well now. Looking forward to further testing.
So Zswap ended up being a much better bet. Is it worth doing some memory management on the new Pi4?
As usual cool video. Thanks so much for your efforts.
I followed your blog and my swap shows 1GiB now. But it shows 0B / 1GiB... shouldn't that be doing something ?
Also, my zram.sh file looks nothing like the one in this video ;-/
#!/bin/bash
cores=$(nproc --all)
modprobe zram num_devices=$cores
swapoff -a
totalmem=`free | grep -e "^Mem:" | awk '{print $2}'`
mem=$(( ($totalmem / $cores)* 1024 ))
core=0
while [ $core -lt $cores ]; do
echo $mem > /sys/block/zram$core/disksize
mkswap /dev/zram$core
swapon -p 5 /dev/zram$core
let core=core+1
done
Your variable labeled "totalmem" needs to be rid of those depreciated backticks. Backticks for command substitution creates subshells which hinder performance of your bash scripts. Proper command substitution uses "$(commands here)" It should look like this:
totalmem="$(free | grep -e '^Mem:' | awk '{print 2}')"
Trust me, I am a bash guru. Brilliant video and very nice work.
I love this. Thank you. I have been looking for ways to use the SD card to add more RAM. There is a way to do it on rooted android devices, so I figured that there surely was some way on this. This is close though and a great idea, I will check that out asap. Is this the pi OS?
Thank you for sharing this resource with us. Now I know of a way to increase the RAM on my Pi.
You aren't increasing your RAM. You are compressing data that is stored in RAM so more is available in the virtual memory space. Overall RAM remains the same.
Your program is different in github as shown in the video. Which one do I need to follow ? Github or the one in this video for Zram. Im having Raspberry pi 3 b+
This is great. I am using Raspian Jessie lite - command line only. Can i do the same configuration for command line? I am a java-nerd so all my rpi apps are in Java.
Thankyou NovaSpirit Tech
What do you recommend to get Conky to launch at boot time? I've seen five different methods and I am still having trouble.
Thanks. I did a PR for your ZRAM script to make it dynamic (so it supports not only Raspberry Pi but other SBCs and even PCs). I intend to utilize this on NEMS Linux (Nagios for Raspberry Pi).
thanks!! i saw your commits, well done. i will be updating the git.
Cool. Thanks for putting it together. I was looking for a decent way to maximize the RAM of the Pi 3 for NEMS, and this looks like a great way. The Pi community are die-hard and while I have many users who don't mind spending extra to get a more powerful SBC, this adds a bit of life to those aging Pi 3's. But now with this PR your script will work on any, so that's great. Thanks for the merge.
Hi, I have a RPi3 with your installation of zRAM that works fine initially but the free RAM decreass over time until the Pi crashes, freezes, locks up apparently due to lack of free space (6-8 hours max with a reboot required to return to a workable state)!!! I am a newb to Linux programming so the detailed Gentoo wiki is going over my head at present. Can you assist with an explanation and hopefully a fix to what I perceive as a memory leak or a fundamentally broken garbage collection routine behind the scenes of zRAM? Other than this it turns the Pi into a fully fledged PC workstation! 1GB of RAM is not enough. 3 tabs open in Chrome crashes the Pi as pop-ups declaring "Not Responding" take up the last workable memory space and effectively lock up the system completely! The Pi Foundation does not appear to recognise this memory issue as a fact at present! zRAM makes the differences clear to appreciate. Thank you for all your efforts. Very much appreciated (heroic applause!)
While using Z-RAM, does it require you to lose some storage other than installing the program?
I use a single raspberry pi 3 b+ to host a small minecraft server as a test server, would this improve the server lag in any way
is their a reason why those like me with the pi zero are getting ignored on this particular ZRAM topic? "does this work on a zero? " im yet to buy one in micro center for $4.99 and i would like to know about this prior to buying, thanks in advance!
I want to know it too, i’m trying to do it right now
Also how does ZRAM compare to ZSWAP? Or does it matter on the OS of the raspberry pi?
I have a linux system with 8Gb of Ram ( Suggestion Size for swamp memory is double that of the ram you have) so i made my swp Memory 16Gb. Would it be any benefit for me to make zram for my system or is it better for me to leave as is? I have read some blogs on how you can make zram the primary and swap secondary. Would this be any benefit to go this route or to leave as is? Im just curious because my swp has saved many times from crashing my programs from running too many virtual machines at one time, and im just seeking alternative ways to help my memory close calls issues. Im just curious on you take on this matter. I looking forward to anyone's response on this subject.
theres a new script and idk if it worked because in htop it only say Ok/Ok under the section Swp. Pls help
Utterly fantastic!
I have followed the instructions exactly, but when i reboot my machine my swap is only at 497mb I am using a RPi2 with Ubuntu Mate, any clue what might be wrong?
For anyone who is interested i figured out how to fix this in Ubuntu, you need to edit > /usr/bin/init-zram-swapping and replace everything with the script that Nova has supplied and then it will work properly :) Now I just need to figure out how to get conky to launch automatically with Ubuntu Mate and LXDE!
What is 1024 representing? It is used to multiply 1/4 of the totalmem variable (if totalmem is not a variable, feel free to correct me, I don't know bash scripting). I initially assumed that it represented the Pi 3's RAM in MB, but in the zram script that debian has posted, it uses 1024 as a value like this: print $1*1024;
so at a complete guess could it be compressing 1gb of ram (1024mb) and keeping 1024mb uncompressed so the system didn't slow down due to compression overhead.
The pagefile could be 2x ram (4096mb) and 1/4 of it would be 1024mb.
This is my guess
After reboot my ram are only 114 mb. How to fix it ? Thank you.
I like conky! I have installed it on my virtual debian linux box as well. I use the same script as on RPI but the background comes out black and not transparent. Any clue why? Thanks!
how do you run wbar? I installed "sudo apt-get install wbar wbar-config" but it not displayed on the screen ? Can you show me?
its not wbar-config its wbar.config
logout of your session and log back in
Hi Don, I got the image from the git. But now I want to change my ssd. My ssd seems to be locked and I don't have permission to reformat my sdd. Tried to gparted and I have no permission. halp. thanks
How do you get the system display graph is there a way to install it
Don, I am running Raspian with persistence from a USB, because my windows 10 hard drive crapped out on me on a Dell Desktop. I figured why not since all my other computers are Raspberry pi's or running some variant of Debian. This computer has two cpu's AMD Athlon(tm) II X2 250 Processors they are dual core (so together 4 cores). Regardless of the internal RAM and the SWAP space would enabling ZRAM increase performance. Its not slow by any means, but today a decent computer comes stock with 8gb RAM out of the box. This computer is right now the command and control for my small army of Pi's and other Linux boxes so every bit helps. If you could get back I would appreciate it, thanks.
wow same here, my hard drive also went
Look forward to more videos
Thank you
if it doesn't work for anyone check the Exec line: make sure it goes Exec=sh /usr/bin/conky.sh ...fixed it for me
Somebody can say me if this actually increase performance? For example I'm hosting minecraft server, will this reduce lag? A little bit?
Does ZRAM work for the pi Zero? If so do I have to change the config file?
Swap file will not increase performance of your system. However, it will let you run applications when you used all of your RAM capacity.
My pi3 is so slow in streaming videos. I wish if I could have increase the ram a little bit so that I can browse internet and watch videos without buffering.
how can i get that rpi linux monitor that you have on your desktop?
I don’t think you can just DOWNLOAD extra storage...........
totally awesome, thank you for this nice hack to prolong life of SD card
How does zram fair for GPU/vram
You didn't speak too much about loading and running Conky. How does it start? Also looking at your "read me" file on GITHUB, I noticed you are missing the term "sudo" on the "download the conkyrc file to home directory as .conkyrc" command line "wget -O /home/pi/.conkyrc raw.githubusercontent.com/novaspirit/rpi_conky/master/rpi3_conkyrc
Is there any way to make youtube video look better on raspian. It is lagging a lot. I was hoping that this ram/swap solution would fix it but it has not...?
you would need to add more ram to your video and make sure you use chromium with the h264ify extension which forces youtube to serve videos in a format which can be accelerated by the pi's hardware
Thanks, excellent suggestion!
So it's like vram? v as in virtual. On windows?
@NovaspiritTech do you how can I change the degree display from celcius to farenheit in conky?
REPLY
Ommar del Rio F = C × 1.8 + 32 . . . . Math is cool. You may have to read the conky wiki to figure out how to make math work though
so how does this Increase the Ram on the pi just wondering?
...no. A Swap partition is basically just using the Hard drive (or flash media, or whatever you have the OS installed on) as RAM... albeit at a much much much slower rate.
So while yes this will give you "more ram" it probably won't have much of an effect, hell it might even slow the system down.
It doesn't, it effectively will compress rarely used sections of memory to free up some space, but it's not adding any memory to your device at all.
Was going to say get the soldering iron out. But the chip doesn't have external ram on the board :(
It's called Bullshit. It's been going for many years.
We used to call this "Virtual Memory," back in the '90s, before it became so commonplace, you didn't even get to choose how much of your HDD, etc. RAM you'll allow the OS to use, for it.
What is the command to see if the file worked correctly?
Where is the zRAM coming from if it's not from the SDCard?
For whom which is trying to write the correct word of the lightweight free system monitor shown in the video, the name is "Conky". Who doesn't have English as a mother language is having trouble to find it.
Hi my dear friend!!! First of all, congratulations for video!!! What software should I install to have this window with raspberry's informations on my desktop like you?
hi and thanks for the video. is there a way to use these feature on an android tv box ?
This seems really sketchy, can somebody show me some sources that say this will work? I am quite skeptical.
How did you press to save that change?
Awesome video, Thanks!
By the way, any ideas on how to make a portable display for raspberry pi and a powerbank?
I was thinking on using phone batteries
i did something like that on my kali linux video th-cam.com/video/6xXnUGR_e4E/w-d-xo.html using a powerbank that is normally used to charge phones with a 5" touchscreen display.
send me the Conky Theme Link which u used in Raspberry pi , please, I could't find it in Devientart.
Has this been at all tested on Retro Pi? and has it at all effected any of the emulators like the N64 etc etc? i'm currently using the Raspberry Pi 3 and was curious about it.
2gb is way more than any retro gaming console. the xbox 360 has 512mb of ram. RetroPi doesn't need more ram. Faster ram might help the emulator run better on PlayStation games but this mod will slow the ram as it has to compress and dump to storage.
Don't bother with this for RetroPi it won't help
Noob Alert! I'm using a Raspbian system on a very old PC. Will this help me boost VRAM? Is there a way to do it all with the terminal?
Worked fine for me, how do you get conky looking nice like yours, the original one really kills my screen :D
May I ask how to get these neat stats on the desktop, too?
How about Download more Ram?
which reminds me that zram swap can also works on my android
when i go to gnu nano and put
/usr/bin/zram.sh
this comes up [ Directory '/usr/bin' is not writable ]
i can not change permissions HELP !!!!!!!!!!!!!!!!!!!!!!!!!
CD /
to the directory of the file u want to change permission on
Then I believe
sudo chown pi:root *filename*
Should give u permissions
This is helpful.
How are you recording the screen?
Swap space isn't ram and its slower by 30x or more.. and compression of the data into ram is also very very slow.. they don't do it on real desktop computers or laptops because it is not worth it and has the same issues as a raspberry pi.. your better of leaving the swap space as stock and not compressing the ram..
Finely found Conky, (or however it's spelled!) Does it ONLY work with a: Pi 3 ?
Also, where is zram?
zram is apparently installed with the pi
There has to be a downside to this other than small CPU cycles?
Why don't all Android devices use this for example?
You could even have a small, low cost, co-processor to deal with the task...
Just sounds too good to be true to me :-)
I see your running HTOP. I also suggest joe, (it's like Wordstar of the 80's), also mc, it looks like norton DOS util.
has the Zram file been erased from Github?????
You install xfce to Rasbian? How?
Hey man, I love your videos! You rock.
I went to your site and got your conky config file, thank you for that. I was wondering if you could help us noobs get conky to boot up on start up.
Thanks, RP
Also I cannot get the conky config file to work in Kali. What folder should it be placed in. Thanks!
hi how do you save this script in bin folder because the terminal says that i cannot save due to permission
try typing the command "sudo" before all the lines of code .
on every line
Does this work on a Pi Zero?