Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3546

Raspberry Pi OS • How to use ZRAM temporarily

$
0
0
It is possible to use ZRAM without any change to the permanent installation of the system.
No download is nessesarry to use it.
To use it manually like this, the size should be set to something sensible.
This is how I use it frequently:

Code:

sudo modprobe zramsudo zramctl /dev/zram0 --algorithm zstd --size 1Gsudo mkswap -U clear /dev/zram0sudo swapon --priority 100 /dev/zram0
with one exception, I use 8G instead of 1G on my 4G pi4. This is the uncompressed size.
I specified just 1G in the code snippet so more people can try it without editing it first.

With 8G on my 4Gpi4 the RAM used for the ZRAM swap is neglible when empty and about 1.2G when half full, and about 2.5G full. Compression ratio tend to be from 3.1 to 3.5+ when chromium use most of the RAM.

I modify the following parameters to increase swapping, as the swapping is to RAM, and i want the compression to begin earlier.

Code:

sudo sysctl vm.vfs_cache_pressure=500sudo sysctl vm.swappiness=100sudo sysctl vm.dirty_background_ratio=1sudo sysctl vm.dirty_ratio=50
Looking at these parameters without changing them can be done by not specifying = and the following number.

To look at the status of the swap try these commands

Code:

free -mvmstat -scat /proc/swapszramctl
Hope this helps

Statistics: Posted by ArcticAurora — Sat Jan 20, 2024 9:56 am



Viewing all articles
Browse latest Browse all 3546

Trending Articles