Beorn_Bear
Posts: 126
Joined: Tue Feb 27, 2018 6:04 pm
Location: Vancouver, Canada

Zram and/or swap file for Raspberry Pi 4 recommended??

Sat Jul 20, 2019 5:24 pm

What would you recommend for Zram and/or swap files?! Would it work better on a usb flash key?! Is there significant improvement on performance on a Raspberry 4?!

wildfire
Posts: 639
Joined: Sat Sep 03, 2016 10:39 am
Location: Dundee, Scotland

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sat Jul 20, 2019 5:30 pm

Only lightly used at the moment but my 4Gb is not using swap at all, so my answer is leave well alone.

It may help if you specify how much RAM you have,
E8 85 A2 64 C9 64 81 94 64 81 95 64 89 84 89 96 A3
Still NF Shirls

Andyroo

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sat Jul 20, 2019 5:34 pm

Folk have ran Zram on 3B+ here before and seen advantages.
Others have run a decent swap file on HDD / SSD and seen advantages

I would not run a swap file of USB stick or SD card due to wear levelling.

Given the cost of these boxes I would say if you have lots of apps running and eating memory, look to off load some onto another Pi :lol:

Just keep an eye on memory use - if you need it move to HDD / SSD and set up a decent sized one.

RonR
Posts: 1389
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sat Jul 20, 2019 5:46 pm

The attached scripts will allow you to quickly install/remove zram so you can evaluate it yourself.
Attachments
zram.zip
(1.07 KiB) Downloaded 332 times

pik33
Posts: 192
Joined: Thu Sep 10, 2015 4:26 pm

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sat Jul 20, 2019 6:01 pm

I made a real swap partition for RPi4/4GB and it seems it is not used at all. The amount of free ram is huge even when a lot of internet pages are open. I uninstalled dphys-swapfile. The swap partition sits there and waits for ram eating tasks.

Code: Select all

              total        used        free      shared  buff/cache   available
Mem:        3999788      373568     3072864      102876      553356     3399576
Swap:       4194300           0     4194300
This is what it looks like with Chromium and RPi forum is open (I am posting from this Pi right now)

Musketeer
Posts: 166
Joined: Fri Feb 12, 2016 1:23 pm
Location: CZ

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sat Jul 20, 2019 7:34 pm

There are people who have /tmp + /log or some other dirs mapped to RAM so it s definitely much useful trick then temp file...
Linux is like woman - both wants 180 % of your time...
You want speed Java 9.8x? Throw it out of some Window(s)!
My girlfriend is terribly unmature - she always sinks my boats in bathtub!

bluenote
Posts: 116
Joined: Thu Feb 05, 2015 8:25 am

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sun Jan 19, 2020 6:18 pm

RonR wrote:
Sat Jul 20, 2019 5:46 pm
The attached scripts will allow you to quickly install/remove zram so you can evaluate it yourself.
How can I confirm this worked properly?
Thanks

RonR
Posts: 1389
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sun Jan 19, 2020 7:22 pm

bluenote wrote:
Sun Jan 19, 2020 6:18 pm
RonR wrote:
Sat Jul 20, 2019 5:46 pm
The attached scripts will allow you to quickly install/remove zram so you can evaluate it yourself.

How can I confirm this worked properly?
Thanks

Run 'lsblk' and 'blkid'.

bluenote
Posts: 116
Joined: Thu Feb 05, 2015 8:25 am

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sun Jan 19, 2020 8:55 pm

RonR wrote:
Sun Jan 19, 2020 7:22 pm
bluenote wrote:
Sun Jan 19, 2020 6:18 pm
RonR wrote:
Sat Jul 20, 2019 5:46 pm
The attached scripts will allow you to quickly install/remove zram so you can evaluate it yourself.

How can I confirm this worked properly?
Thanks

Run 'lsblk' and 'blkid'.
Thanks. Those results don't reference anything that I don't already recognize. Do I need to install something else first?

RonR
Posts: 1389
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sun Jan 19, 2020 9:46 pm

bluenote wrote:
Sun Jan 19, 2020 8:55 pm
RonR wrote:
Sun Jan 19, 2020 7:22 pm
bluenote wrote:
Sun Jan 19, 2020 6:18 pm


How can I confirm this worked properly?
Thanks

Run 'lsblk' and 'blkid'.
Thanks. Those results don't reference anything that I don't already recognize. Do I need to install something else first?

You should be seeing something like:

root@FreePBX:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
...
zram0 254:0 0 242.4M 0 disk [SWAP]
zram1 254:1 0 242.4M 0 disk [SWAP]
zram2 254:2 0 242.4M 0 disk [SWAP]
zram3 254:3 0 242.4M 0 disk [SWAP]
root@FreePBX:~# blkid
...
/dev/zram0: UUID="1a7d56ba-29bc-4b13-b19a-68daf02465fa" TYPE="swap"
/dev/zram1: UUID="b664b23f-f285-4f9f-bdae-3c9f8519497e" TYPE="swap"
/dev/zram2: UUID="b8642edf-0c50-45b9-a562-6d0673035e05" TYPE="swap"
/dev/zram3: UUID="eb9c60c0-e8f1-4190-863b-f61ecf1123e9" TYPE="swap"

bluenote
Posts: 116
Joined: Thu Feb 05, 2015 8:25 am

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sun Jan 19, 2020 9:55 pm

RonR wrote:
Sun Jan 19, 2020 9:46 pm
bluenote wrote:
Sun Jan 19, 2020 8:55 pm
RonR wrote:
Sun Jan 19, 2020 7:22 pm


Run 'lsblk' and 'blkid'.
Thanks. Those results don't reference anything that I don't already recognize. Do I need to install something else first?

You should be seeing something like:

root@FreePBX:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
...
zram0 254:0 0 242.4M 0 disk [SWAP]
zram1 254:1 0 242.4M 0 disk [SWAP]
zram2 254:2 0 242.4M 0 disk [SWAP]
zram3 254:3 0 242.4M 0 disk [SWAP]
root@FreePBX:~# blkid
...
/dev/zram0: UUID="1a7d56ba-29bc-4b13-b19a-68daf02465fa" TYPE="swap"
/dev/zram1: UUID="b664b23f-f285-4f9f-bdae-3c9f8519497e" TYPE="swap"
/dev/zram2: UUID="b8642edf-0c50-45b9-a562-6d0673035e05" TYPE="swap"
/dev/zram3: UUID="eb9c60c0-e8f1-4190-863b-f61ecf1123e9" TYPE="swap"
Yep, and I don't

X-Gen
Posts: 91
Joined: Fri Dec 06, 2019 12:08 pm

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sun Jan 19, 2020 10:15 pm

I've been unsuccessfully looking at USB to ddr ram converters.
Isa/pcie to ram does exist, but the pi doesn't have a pcie slot available.

The second best thing is probably a Corsair Voyager GTX.
It's SSD speeds over USB, and at USB sizes!

It would be good to install your OS as well as swap on that.
And in case you have a quadcore cpu, zram is good; but it will slow down a pi zero.

RonR
Posts: 1389
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sun Jan 19, 2020 10:21 pm

bluenote wrote:
Sun Jan 19, 2020 9:55 pm
Yep, and I don't

I just downloaded it from above and ran it on a fresh copy of Raspbian:

Code: Select all

pi@raspberrypi:~ $ sudo ./install-zram

Install ZRAM (y/n)? y

pi@raspberrypi:~ $ lsblk
...
zram0       254:0    0 987.4M  0 disk [SWAP]
zram1       254:1    0 987.4M  0 disk [SWAP]
zram2       254:2    0 987.4M  0 disk [SWAP]
zram3       254:3    0 987.4M  0 disk [SWAP]
pi@raspberrypi:~ $ sudo blkid
...
/dev/zram0: UUID="c830c4ee-8cc0-4771-9302-f56c87b0c24d" TYPE="swap"
/dev/zram1: UUID="3db85f82-de60-463c-9aba-ee9f90584aab" TYPE="swap"
/dev/zram2: UUID="35aab04f-2a75-4f62-91c7-6eae74d45f6e" TYPE="swap"
/dev/zram3: UUID="c2dd0da4-fff1-4be5-aa93-dea543483fdc" TYPE="swap"

bluenote
Posts: 116
Joined: Thu Feb 05, 2015 8:25 am

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sun Jan 19, 2020 10:25 pm

Oh man, I am so sorry. I have a set up with a few monitors and multiple sessions going, and somehow ... I got confused about which session I installed in ....... Thank you this did work and sorry to raise a stupid false alarm. PEBKAC :(

RonR
Posts: 1389
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sun Jan 19, 2020 10:29 pm

bluenote wrote:
Sun Jan 19, 2020 10:25 pm
Oh man, I am so sorry. I have a set up with a few monitors and multiple sessions going, and somehow ... I got confused about which session I installed in ....... Thank you this did work and sorry to raise a stupid false alarm. PEBKAC :(

Not to worry -- it happens to all of us.

jinda
Posts: 13
Joined: Sun Jan 03, 2016 9:29 pm

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sun May 24, 2020 8:14 pm

So it tried it out on new installed Raspbian Buster 2020-02-13.

Then I did this which not the best but whatever. :lol:
Maybe we can learn something I hope. :D

"sudo ./install-zram"
Doesn't work did nothing.

Figured I try
"sudo sh install-zram"
That worked. I think I had the program in the wrong directory.
That's why "./" didn't work but I don't know.

Then ran Chromium with a Netflix video playing.
Opened up an other tap opened up a large random website.
The video would stop and not play again till reload page.

Then
"sudo ./remove-zram"
Doesn't work did nothing.

Figured I try
"sudo sh remove-zram"
That errors out goes into a loop.

I looked at the program figured out to to rem out the zram in /etc/rc.local.
I did something that worked.

Then ran Chromium with a Netflix video playing.
Opened up an other tap opened up a large random website.
The video would "shutter" but not lockup.

The zram is not working for me.

Thanks

RonR
Posts: 1389
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Sun May 24, 2020 10:32 pm

jinda wrote:
Sun May 24, 2020 8:14 pm
"sudo ./install-zram"
Doesn't work did nothing.

You didn't see the following when you ran 'sudo lsblk'?:

Code: Select all

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
.
.
.
zram0       254:0    0 242.4M  0 disk [SWAP]
zram1       254:1    0 242.4M  0 disk [SWAP]
zram2       254:2    0 242.4M  0 disk [SWAP]
zram3       254:3    0 242.4M  0 disk [SWAP]
jinda wrote:
Sun May 24, 2020 8:14 pm
Figured I try
"sudo sh install-zram"
That worked. I think I had the program in the wrong directory.
That's why "./" didn't work but I don't know.

If the script wan't in the current directory, You should not have used the 'sh' and should have simply used:

Code: Select all

sudo install-zram
jinda wrote:
Sun May 24, 2020 8:14 pm
Figured I try
"sudo sh remove-zram"
That errors out goes into a loop.

Again, ditch the 'sh'.

jinda
Posts: 13
Joined: Sun Jan 03, 2016 9:29 pm

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Mon May 25, 2020 1:59 am

Thanks! I am just trying to learn I something.
I got it to work
I did the following when when ran 'sudo lsblk'

Hear is what I did and what I got.
I really think it works I don't think I helped.
I did something wrong or it just hates chromium which is has a mod to play netflix.

Copied the zip is a folder and unzipped and in that folder ran:

sudo sh remove-zram
Remove ZRAM (y/n)? remove-zram: 11: read: Illegal option -n
swapoff: /dev/zram0: swapoff failed: No such file or directory
remove-zram: 28: remove-zram: CORE: not found

sudo ./remove-zram
sudo: ./remove-zram: command not found

sudo remove-zram
sudo: remove-zram: command not found

sudo ./install-zram
sudo: ./install-zram: command not found

sudo install-zram
sudo: install-zram: command not found

sudo sh install-zram

ZRAM already installed


Later

jinda
Posts: 13
Joined: Sun Jan 03, 2016 9:29 pm

Re: Zram and/or swap file for Raspberry Pi 4 recommended??

Mon May 25, 2020 3:16 am

Sorry!
The program works
You need to do chmod 755 on the file first.
Should have figured that out the first time.
I will reinstall and run my silly test again.
See whats happens.

Later

Return to “General discussion”