Page 1 of 1

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

Posted: Sat Jul 20, 2019 5:24 pm
by Beorn_Bear
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?!

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

Posted: Sat Jul 20, 2019 5:30 pm
by wildfire
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,

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

Posted: Sat Jul 20, 2019 5:34 pm
by Andyroo
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.

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

Posted: Sat Jul 20, 2019 5:46 pm
by RonR
The attached scripts will allow you to quickly install/remove zram so you can evaluate it yourself.

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

Posted: Sat Jul 20, 2019 6:01 pm
by pik33
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)

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

Posted: Sat Jul 20, 2019 7:34 pm
by Musketeer
There are people who have /tmp + /log or some other dirs mapped to RAM so it s definitely much useful trick then temp file...

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

Posted: Sun Jan 19, 2020 6:18 pm
by bluenote
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

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

Posted: Sun Jan 19, 2020 7:22 pm
by RonR
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'.

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

Posted: Sun Jan 19, 2020 8:55 pm
by bluenote
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?

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

Posted: Sun Jan 19, 2020 9:46 pm
by RonR
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"

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

Posted: Sun Jan 19, 2020 9:55 pm
by bluenote
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

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

Posted: Sun Jan 19, 2020 10:15 pm
by X-Gen
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.

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

Posted: Sun Jan 19, 2020 10:21 pm
by RonR
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"

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

Posted: Sun Jan 19, 2020 10:25 pm
by bluenote
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 :(

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

Posted: Sun Jan 19, 2020 10:29 pm
by RonR
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.

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

Posted: Sun May 24, 2020 8:14 pm
by jinda
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

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

Posted: Sun May 24, 2020 10:32 pm
by RonR
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'.

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

Posted: Mon May 25, 2020 1:59 am
by jinda
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

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

Posted: Mon May 25, 2020 3:16 am
by jinda
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