Using zram and zswap in Linux

preview_player
Показать описание
In this video I describe the differences between zram and zswap, their use cases, and how to set them up.

Support the channel:
BTC - 3NzWDDH3n5PsBKqWJyAb7rvsGvJKxcAPFv
ETH - 0xB09212235c648a448F0E7eEB416ce5652362c772

Follow me:
SecureRandom on YouTube -

SecureRandom on LBRY / Odysee -

----------------------------------------------------
zram commands:

zram

options zram num_devices=1

KERNEL=="zram0", ATTR{disksize}="512M",TAG+="systemd"

[Unit]
Description=Swap with zram

[Service]
Type=oneshot
RemainAfterExit=true
ExecStartPre=/sbin/mkswap /dev/zram0
ExecStart=/sbin/swapon -p 5 /dev/zram0
ExecStop=/sbin/swapoff /dev/zram0

[Install]

sudo systemctl enable zram

----------------------------------------------------
zswap commands:

Check if zswap is enabled / supported
cat /sys/module/zswap/parameters/enabled

sudo vim /etc/default/grub
Рекомендации по теме
Комментарии
Автор

6:33 zswap is such a great feature! It seems to work similarly to how macOS compresses idle RAM. I have 16GB RAM and 10GB of swap, but decided to enable zswap anyway because it's just a much better use of resources.

LeeZhenYong
Автор

Hey thanks! Even two years later its relevant. I want to use zram for temporary. Because it will increase lifespan of SSD because they can only do so many overwrites. Browsing the internet pretty much chews up my SSD. It hasn't gone bad yet, but it will one day. I just hope it doesn't require SystemD because I prefer other init. Anyway thanks!

jarroddeskins
Автор

i have-
physical ram: 4G
/swapfile size: 4G
zram size: 512M
zswap: enable

what can i change to impove performance.

cosmo_
Автор

I had to disable zram swap because I experienced a strange issue where Firefox would load directly into it, even though I have 128 GB of RAM. Also, whenever the 4 GB swap got filled by Firefox, it would result in a hard crash.

cosmicusstardust
Автор

I use artix linux, which has runit as init system, will this work ?
Can you show like runit service script for that ?

linuxinside
Автор

i got 32gb ram but my manjaro only use ~3gb, can Zswap help me to get better performance ?.

juanluucas
Автор

what is your hint?
i am using 4gb swap partition an 32gb ram.
now, i need more swap. can i create 10gb swap file and add with zswap the 4gb partition?

chrisdanger-godlike
Автор

Super good and helpful video, Thanks!

AmidMajd
Автор

can you please tell me how to change compression algorithm in zram?

rustydust
Автор

Will Zram be better for an eMMC laptop with 4GB ram?

linusman
Автор

You sound almost exactly like the guy from The Action Lab on youtube. 😃

Bonezr
Автор

actually priority in linux goes this way -20 highest priority to 19 lowest priority

RohithGolle
Автор

Is it only me or do you kinda sound like Stitch?

ariel_chess
Автор

I thought lower numbers -3 vs -2 or, say 0 actually have a HIGHER priority (i.e. -20 is highest priority and 19 is lowest priority).

lordofthemound
Автор

sudo apt install zram-tools
sudo nano /etc/default/zramswap -->

ALGO=lz4
PERCENT=25


Done. Nothing more to change.

fatpanda