# Enabling ZRAM in EndeavourOS

**URL:** <https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746>\
**Category:** Newbie\
**Created:** [February 25, 2023, 12:25am UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746 "2023-02-25T00:25:21Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![flyingcakes](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/flyingcakes/32/6218_2.png) [@flyingcakes](https://forum.endeavouros.com/u/flyingcakes)\
**Post date:** [March 1, 2023, 5:48pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/21 "2023-03-01T17:48:26Z")

</div>

> [@mihalycsaba](#):
>
> Aproximately how much more ram space I will get out of this? 10%? Or more?

You can set that in your ZRAM config.

My systems with 8 GB or 16 GB RAM work well with 50% ZRAM size. No slowdowns.

On my old desktop with a dual core processor and 4 GB RAM, I couldn’t go past 25% (i.e. 1 GB ZRAM).

So its dependent on your system specs.

Talking about use case, ZRAM comes in very handy when I’m multitasking, running many apps at once, and usually also having VM running in background. On the other hand, when compiling applications, I rarely ever see significant ZRAM usage.

> [@mihalycsaba](#):
>
> I have 14 gigs, and I had situations where it wasn’t enough and the system slowed down a lot, even with a nvme ssd.

Once you go out of memory, system _will_ slow down, irrespective of your storage backend. Have swap space, so that your system doesn’t suddenly become unresponsive. Again, ZRAM will surely help with this.

> [@mihalycsaba](#):
>
> But I guess, I will still need a regular swapfile.

I don’t know your exact use case, but I don’t see a reason why you would want a normal swapfile if ZRAM can do what you want to.

> [@mihalycsaba](#):
>
> Is lz4 the fastest?

Technically, speaking it should be. (unless my memory is going haywire)

LZO and LZ4 are almost similar. ZSTD is slightly slower, but offers slightly better compression too.

PS. I’m not an expert at compression algorithms, so if someone spots a mistake, please comment 🙂

---

<div class="post-metadata">

**Author:** ![VolantesMagus](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/volantesmagus/32/49259_2.png) [@VolantesMagus](https://forum.endeavouros.com/u/VolantesMagus)\
**Post date:** [March 1, 2023, 11:28pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/22 "2023-03-01T23:28:53Z")

</div>

What is the difference between ZRAM and SWAP

---

<div class="post-metadata">

**Author:** ![dalto](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/dalto/32/5577_2.png) [@dalto](https://forum.endeavouros.com/u/dalto)\
**Post date:** [March 2, 2023, 12:08am UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/23 "2023-03-02T00:08:36Z")

</div>

> [@VolantesMagus](#):
>
> What is the difference between ZRAM and SWAP

zram is compressed swap in ram.

zswap is is a compressed cache that sits in front of your normal swap.

---

<div class="post-metadata">

**Author:** ![mbod](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/mbod/32/16833_2.png) [@mbod](https://forum.endeavouros.com/u/mbod)\
**Post date:** [March 2, 2023, 2:31pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/24 "2023-03-02T14:31:13Z")

</div>

> [@mihalycsaba](#):
>
> So if I enable this, it will use all my ram as a compressed swap? Aproximately how much more ram space I will get out of this? 10%? Or more?

I installed Fedora on my laptop. It has 8 GB of RAM and Fedora sets zram-size to 8 GB. I was surprised when I first saw that, but this is in fact the default setup for 8GB RAM. Nicely explained in this wiki article.

[https://fedoraproject.org/wiki/Changes/SwapOnZRAM](https://fedoraproject.org/wiki/Changes/SwapOnZRAM)

This article also answers your questions about the net memory gain of zram. It reads:

- _A system has 16 GiB RAM. The proposed defaults suggest the /dev/zram0 device will be 4 GiB. If the workload completely fills up swap with 4 GiB of anonymous pages, what’s happened? The zramctl command will display the true compression ratio. If 2:1 is really obtained, it means 4GiB swap data is compressed to 2GiB. Therefore 2GiB is the actual RAM usage, and is also the net effective eviction. i.e. 4 GiB anonymous pages are evicted, but are then compressed and pinned into 2 GiB RAM, for a net memory savings of 2 GiB._

In an nutshell: 50 % of the zram-size is the netto gain in memory.

---

<div class="post-metadata">

**Author:** ![mihalycsaba](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/mihalycsaba/32/70916_2.png) [@mihalycsaba](https://forum.endeavouros.com/u/mihalycsaba)\
**Post date:** [May 21, 2023, 12:50pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/25 "2023-05-21T12:50:01Z")

</div>

Is my zswap disabled?  
I checked the wiki, it says the same on how to disable.

```auto
[csaba@csaba-mini ~]$ sudo dmesg | grep zswap    
[sudo] password for csaba: 
[0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-linux-zen root=UUID=5570a0d2-c1ef-4128-af09-0e7f8a2d5b34 rw nowatchdog quiet nvme_load=YES loglevel=3 zswap.enabled=0
[0.024231] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-linux-zen root=UUID=5570a0d2-c1ef-4128-af09-0e7f8a2d5b34 rw nowatchdog quiet nvme_load=YES loglevel=3 zswap.enabled=0
[0.594933] zswap: loaded using pool zstd/zsmalloc
[csaba@csaba-mini ~]$ grep -R . /sys/module/zswap/parameters
/sys/module/zswap/parameters/same_filled_pages_enabled:Y
/sys/module/zswap/parameters/enabled:N
/sys/module/zswap/parameters/max_pool_percent:20
/sys/module/zswap/parameters/compressor:zstd
/sys/module/zswap/parameters/non_same_filled_pages_enabled:Y
/sys/module/zswap/parameters/zpool:zsmalloc
/sys/module/zswap/parameters/accept_threshold_percent:90

```

---

<div class="post-metadata">

**Author:** ![pebcak](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/pebcak/32/100472_2.png) [@pebcak](https://forum.endeavouros.com/u/pebcak)\
**Post date:** [May 21, 2023, 1:22pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/26 "2023-05-21T13:22:47Z")

</div>

> [@mihalycsaba](#):
>
> `/sys/module/zswap/parameters/enabled:N`

I think this shows that it is disabled. The N would mean that none of the parameters listed in your output would actually have any effect I guess.

---

<div class="post-metadata">

**Author:** ![endeavouros-user](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/endeavouros-user/32/103262_2.png) [@endeavouros-user](https://forum.endeavouros.com/u/endeavouros-user)\
**Post date:** [January 7, 2024, 11:17pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/27 "2024-01-07T23:17:06Z")

</div>

Sorry for asking questions after 7+ months from the last reply. What I understood from this post that I shall disable zswap and only leave zram enabled for efficient use. Do I have to set a dedicated partition for swap as I want my machine to be suspended while I am away? I guess hibernate won’t be necessary as it’s a laptop, always stays on desk.

---

<div class="post-metadata">

**Author:** ![BluishHumility](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/bluishhumility/32/70412_2.png) [@BluishHumility](https://forum.endeavouros.com/u/BluishHumility)\
**Post date:** [January 8, 2024, 12:21am UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/28 "2024-01-08T00:21:27Z")

</div>

No, you do not need a swap file or swap partition for the suspend state like you do for hibernation.

If down the road you change your mind and would like to set up hibernation, it’s pretty easy to make a swap file for that.

---

<div class="post-metadata">

**Author:** ![endeavouros-user](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/endeavouros-user/32/103262_2.png) [@endeavouros-user](https://forum.endeavouros.com/u/endeavouros-user)\
**Post date:** [January 8, 2024, 12:27am UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/29 "2024-01-08T00:27:19Z")

</div>

Thank you so much for the clarification.

---

<div class="post-metadata">

**Author:** ![BluishHumility](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/bluishhumility/32/70412_2.png) [@BluishHumility](https://forum.endeavouros.com/u/BluishHumility)\
**Post date:** [January 8, 2024, 12:30am UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/30 "2024-01-08T00:30:27Z")

</div>

No problem. 🙂

By the way, welcome to the community @endeavouros-user. 👋

---

<div class="post-metadata">

**Author:** ![alex5402](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/alex5402/32/96543_2.png) [@alex5402](https://forum.endeavouros.com/u/alex5402)\
**Post date:** [April 26, 2024, 7:44pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/31 "2024-04-26T19:44:49Z")

</div>

> [@mbod](#):
>
> [https://github.com/systemd/zram-generator/blob/main/man/zram-generator.conf.md](https://github.com/systemd/zram-generator/blob/main/man/zram-generator.conf.md)

can anyone tell me where i set the swappyness for zram i forgot

---

<div class="post-metadata">

**Author:** ![manfredlotz](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/manfredlotz/32/56126_2.png) [@manfredlotz](https://forum.endeavouros.com/u/manfredlotz)\
**Post date:** [April 27, 2024, 3:22am UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/32 "2024-04-27T03:22:15Z")

</div>

See [https://wiki.archlinux.org/title/Zram](https://wiki.archlinux.org/title/Zram). This page shows some recommended settings which are already set on my system.

Generally:

- if you want to set values you can define them in files in `/etc/sysctl.d` . Then they will be taken after boot.
- if you want to set a value in a running system use `sysctl`

---

<div class="post-metadata">

**Author:** ![alex5402](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/alex5402/32/96543_2.png) [@alex5402](https://forum.endeavouros.com/u/alex5402)\
**Post date:** [April 27, 2024, 2:36pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/33 "2024-04-27T14:36:59Z")

</div>

ok

---

<div class="post-metadata">

**Author:** ![abhishek\_parihar](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/b4bc9f/32.png) [@abhishek\_parihar](https://forum.endeavouros.com/u/abhishek_parihar)\
**Post date:** [May 5, 2024, 10:25am UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/34 "2024-05-05T10:25:19Z")

</div>

Hey, I followed you youtube video but zram is not created for me, the script is totally changed please could you look into it, My pc has 7.1GiB ram + 512MB integrated graphics:

```auto
# This file is part of the zram-generator project
# https://github.com/systemd/zram-generator

[zram0]
# This section describes the settings for /dev/zram0.
#
# The maximum amount of memory (in MiB). If the machine has more RAM
# than this, zram device will not be created.
#
# "host-memory-limit = none" may be used to disable this limit. This
# is also the default.
host-memory-limit = none

# The size of the zram device, as a function of MemTotal, both in MB.
# For example, if the machine has 1 GiB, and zram-size=ram/4,
# then the zram device will have 256 MiB.
# Fractions in the range 0.1–0.5 are recommended.
#
# The default is "min(ram / 2, 4096)".
zram-size = ram / 2

# The compression algorithm to use for the zram device,
# or leave unspecified to keep the kernel default.
compression-algorithm = lzo-rle

# By default, file systems and swap areas are trimmed on-the-go
# by setting "discard".
# Setting this to the empty string clears the option.
#options =

# Write incompressible pages to this device,
# as there's no gain from keeping them in RAM
writeback-device = /dev/zvol/tarta-zoot/swap-writeback

# The following options are deprecated, and override zram-size.
# These values would be equivalent to the zram-size setting above.
zram-fraction = 0.5
max-zram-size = 4000

```

---

<div class="post-metadata">

**Author:** ![BluishHumility](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/bluishhumility/32/70412_2.png) [@BluishHumility](https://forum.endeavouros.com/u/BluishHumility)\
**Post date:** [May 5, 2024, 10:42am UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/35 "2024-05-05T10:42:01Z")

</div>

Where did you save the config file you posted? (The exact path.)

Please also post the output of:

```auto
inxi -j

```

---

<div class="post-metadata">

**Author:** ![abhishek\_parihar](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/b4bc9f/32.png) [@abhishek\_parihar](https://forum.endeavouros.com/u/abhishek_parihar)\
**Post date:** [May 5, 2024, 12:41pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/36 "2024-05-05T12:41:17Z")

</div>

I copied the example conf file from:  
`/usr/share/doc/zram-generator/zram-generator.conf.example`

and saved it to:  
`/etc/systemd/zram-generator.conf`

edited the file  
then:` systemctl daemon-reload`  
then: `systemctl start /dev/zram0`

> inxi -j

```auto
Swap:
  Alert: No swap data was found.

```

---

<div class="post-metadata">

**Author:** ![abhishek\_parihar](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/b4bc9f/32.png) [@abhishek\_parihar](https://forum.endeavouros.com/u/abhishek_parihar)\
**Post date:** [May 5, 2024, 12:46pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/37 "2024-05-05T12:46:01Z")

</div>

> The example conf file was:

```auto
# This file is part of the zram-generator project
# https://github.com/systemd/zram-generator

[zram0]
# This section describes the settings for /dev/zram0.
#
# The maximum amount of memory (in MiB). If the machine has more RAM
# than this, zram device will not be created.
#
# "host-memory-limit = none" may be used to disable this limit. This
# is also the default.
host-memory-limit = 9048

# The size of the zram device, as a function of MemTotal, both in MB.
# For example, if the machine has 1 GiB, and zram-size=ram/4,
# then the zram device will have 256 MiB.
# Fractions in the range 0.1–0.5 are recommended.
#
# The default is "min(ram / 2, 4096)".
zram-size = min(ram / 10, 2048)

# The compression algorithm to use for the zram device,
# or leave unspecified to keep the kernel default.
compression-algorithm = lzo-rle

# By default, file systems and swap areas are trimmed on-the-go
# by setting "discard".
# Setting this to the empty string clears the option.
options =

# Write incompressible pages to this device,
# as there's no gain from keeping them in RAM
writeback-device = /dev/zvol/tarta-zoot/swap-writeback

# The following options are deprecated, and override zram-size.
# These values would be equivalent to the zram-size setting above.
#zram-fraction = 0.10
#max-zram-size = 2048

[zram1]
# This section describes the settings for /dev/zram1.
#
# host-memory-limit is not specified, so this device will always be created.

# Size the device to a tenth of RAM.
zram-size = ram / 10

# The file system to put on the device. If not specified, ext2 will be used.
fs-type = ext2

# Where to mount the file system. If a mount point is not specified,
# the device will be initialized, but will not be used for anything.
mount-point = /run/compressed-mount-point

```

---

<div class="post-metadata">

**Author:** ![flyingcakes](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/flyingcakes/32/6218_2.png) [@flyingcakes](https://forum.endeavouros.com/u/flyingcakes)\
**Post date:** [May 5, 2024, 3:10pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/38 "2024-05-05T15:10:32Z")

</div>

> [@abhishek\_parihar](#):
>
> edited the file  
> then:` systemctl daemon-reload`  
> then: `systemctl start /dev/zram0`

Just a sanity check - did you use `sudo`? And did either of the command report errors when you ran them?

Also, could you share the output of this command:

```sh
systemctl status /dev/zram0

```

and

```auto
zramctl

```

---

<div class="post-metadata">

**Author:** ![Schlaefer](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/schlaefer/32/11917_2.png) [@Schlaefer](https://forum.endeavouros.com/u/Schlaefer)\
**Post date:** [May 5, 2024, 4:05pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/39 "2024-05-05T16:05:56Z")

</div>

That’s a detailed example outlining the configuration for advanced users.

You maybe want to set a maximum RAM size and that’s it. No need to specify anything else.

```auto
[zram0]
zram-size = ram / 2

```

---

<div class="post-metadata">

**Author:** ![BluishHumility](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/bluishhumility/32/70412_2.png) [@BluishHumility](https://forum.endeavouros.com/u/BluishHumility)\
**Post date:** [May 5, 2024, 4:31pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/40 "2024-05-05T16:31:00Z")

</div>

I agree that the configuration file you are using is likely the cause of your issue. It is only meant to be an example file, to show some of the options which are possible.

Some of those options need to be set up first before you can use them. For example, you have a writeback device in your config but those need to be configured on their own first: [https://wiki.archlinux.org/title/Zram#Enabling\_a\_backing\_device\_for\_a\_zram\_block](https://wiki.archlinux.org/title/Zram#Enabling_a_backing_device_for_a_zram_block). It is possible the configuration you have specified is simply invalid.

I think the suggestion to set up a simple config with only the zram size is a good one. Then reboot and check that it works as expected. After that, you can add additional options in one at a time if there is something else you want to configure.

[Previous page](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746.md?page=1)

[Next page](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746.md?page=3)
