# 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:** 1

<div class="post-metadata">

**Author:** ![Matvey\_Mochalov](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@Matvey\_Mochalov](https://forum.endeavouros.com/u/Matvey_Mochalov)\
**Post date:** [February 25, 2023, 12:25am UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/1 "2023-02-25T00:25:21Z")

</div>

ZRAM is very efficiently compressing information in the RAM and creates a kind of the virtual SWAP device, which actualy do not takes physical space on yours SWAP partition.  
It comes with a tradeoff of the a little bit perfomance that’s being taken to compress and unpack data. but ZRAM is active by default even on the android so it’s not hard to guess how little we’re paying for having more RAM out of nothing.

1. Install it.

```bash
sudo pacman -Syu zram-generator

```

1. Create config file

```bash
sudo nano /usr/lib/systemd/zram-generator.conf

```

Paste this in ctrl+shift+v in terminal or use gedit/kate isntead of nano:

```plaintext
[zram0]
zram-size=ram
compression-algorithm=zstd
swap-priority=60

```

1. Activate it

```bash
sudo systemctl daemon-reload
sudo systemctl start /dev/zram0

```

1. Check with htop, you should have now a `Swp` parameter, or if you already had swap file, it’s size should increace on the same value as a RAM that you have.  
If not, try to reboot.

- Also you can check is it working by the other way -

```bash
sudo dmesg | grep zram     

```

1. To prevent conflicts, Arch wiki [recommending](https://wiki.archlinux.org/title/Zram) to disable zswap, so lets do it. I have no idea why on wiki there’s no info that you can disable it in the grub.

```bash
sudo nano /etc/default/grub

```

In the line `locate GRUB_CMDLINE_LINUX_DEFAULT` add in the end `zswap.enabled=0"`  
 ![image](https://forum.endeavouros.com/uploads/default/original/3X/5/9/597156389a360f1cb67ba80e082ad26a8387d6d1.png)

1. 
  1. `sudo grub-mkconfig -o /boot/grub/grub.cfg`

2. Check that the zswap is disabled.

```bash
sudo dmesg | grep zswap    

```

1. Reboot.

---

<div class="post-metadata">

**Author:** ![keybreak](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/keybreak/32/9257_2.png) [@keybreak](https://forum.endeavouros.com/u/keybreak)\
**Post date:** [February 25, 2023, 7:21am UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/2 "2023-02-25T07:21:46Z")

</div>

> [@Matvey\_Mochalov](#):
>
> In my opinion, I think it’s would be better to make EndeavourOS to use ZRAM by the default.

Absolutely not, there are a lot of people like myself who have enough RAM to never use or care about any valid reasons to use swap at all.

That should be left to user.

---

<div class="post-metadata">

**Author:** ![Matvey\_Mochalov](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@Matvey\_Mochalov](https://forum.endeavouros.com/u/Matvey_Mochalov)\
**Post date:** [February 25, 2023, 7:56am UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/3 "2023-02-25T07:56:04Z")

</div>

Idk, in my opinion there’s never enough RAM.  
Besides of that, we already have zswap running by the default, which in most of the cases is inferior.

---

<div class="post-metadata">

**Author:** ![keybreak](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/keybreak/32/9257_2.png) [@keybreak](https://forum.endeavouros.com/u/keybreak)\
**Post date:** [February 25, 2023, 8:16am UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/4 "2023-02-25T08:16:30Z")

</div>

> [@Matvey\_Mochalov](#):
>
> Besides of that, we already have zswap running by the default, which in most of the cases is inferior.

Sure, but it doesn’t work if you doesn’t use swap

> The difference compared to zram is that zswap works in conjunction with a swap device while zram is a swap device in RAM that does not require a backing swap device.

(c) [https://wiki.archlinux.org/title/zswap](https://wiki.archlinux.org/title/zswap)

---

<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:** [February 25, 2023, 10:18am UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/5 "2023-02-25T10:18:42Z")

</div>

> [@Matvey\_Mochalov](#):
>
> In my opinion, I think it’s would be better to make EndeavourOS to use ZRAM by the default.

The question of “defaults” is rather tricky. What works for you might not work for others. Any distro (not just EndeavourOS) is most probably being run on a variety of hardware and for various use cases. Its not possible to ship such defaults that suit everyone.

For example,

> [@Matvey\_Mochalov](#):
>
> ```auto
> [zram0]
> zram-fraction = 1.0
> max-zram-size= 8192
> compression-algorithm=zstd
> swap-priority=60
> 
> ```

this is probably a good configuration for you, it certainly is not suitable for my hardware or use case. Yes, the user can change it as per their preferences, but how many will actually change it?

While its won’t _harm_ to ship some sane defaults, its better to stick to vanilla.

All this is personal opinion

That being said, thanks for the guide!

> [@Matvey\_Mochalov](#):
>
> Idk, in my opinion there’s never enough RAM.

I can relate 🫠  
_\*running two virtual machines, while compiling applications on host and sending this message via Firefox on the same machine_

---

<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:** [February 25, 2023, 11:27am UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/6 "2023-02-25T11:27:32Z")

</div>

> [@Matvey\_Mochalov](#):
>
> ```auto
> [zram0]
> zram-fraction = 1.0
> max-zram-size= 8192
> compression-algorithm=zstd
> swap-priority=60
> 
> ```

`zram-fraction` and `max-zram-size` are obsolete. `zram-size` is all you need.

> <https://github.com/systemd/zram-generator/blob/main/man/zram-generator.conf.md>

---

<div class="post-metadata">

**Author:** ![Matvey\_Mochalov](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@Matvey\_Mochalov](https://forum.endeavouros.com/u/Matvey_Mochalov)\
**Post date:** [February 25, 2023, 4:21pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/7 "2023-02-25T16:21:14Z")

</div>

Many thanks.

---

<div class="post-metadata">

**Author:** ![triple1c86](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@triple1c86](https://forum.endeavouros.com/u/triple1c86)\
**Post date:** [February 27, 2023, 1:16pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/8 "2023-02-27T13:16:38Z")

</div>

erm this part didnt work for me: 1. grub-mkconfig -o /boot/grub/grub.cfg  
/usr/bin/grub-mkconfig: line 265: /boot/grub/grub.cfg.new: No such file or directory

erm is this the dracut thing?  
does anybody know how to update dracut one? Sorry if someone already posted it… I’m a noobbbb…  
many thanks!

---

<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:** [February 27, 2023, 1:18pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/9 "2023-02-27T13:18:19Z")

</div>

That command needs `sudo`. It won’t work as a regular user.

---

<div class="post-metadata">

**Author:** ![MindTheGAAP](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/mindthegaap/32/47060_2.png) [@MindTheGAAP](https://forum.endeavouros.com/u/MindTheGAAP)\
**Post date:** [March 1, 2023, 1:44pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/10 "2023-03-01T13:44:55Z")

</div>

What does swap-priority 60 do?

---

<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, 1:49pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/11 "2023-03-01T13:49:59Z")

</div>

When having only one swap device, the priority doesn’t matter.

When using multiple swap devices, you want to edit priorities so as to let both swap devices be used equally.

From [swapon manpage](https://man7.org/linux/man-pages/man2/swapon.2.html)

```auto
Priority
       Each swap area has a priority, either high or low. The default
       priority is low. Within the low-priority areas, newer areas are
       even lower priority than older areas.

       All priorities set with swapflags are high-priority, higher than
       default. They may have any nonnegative value chosen by the
       caller. Higher numbers mean higher priority.

       Swap pages are allocated from areas in priority order, highest
       priority first. For areas with different priorities, a higher-
       priority area is exhausted before using a lower-priority area.
       If two or more areas have the same priority, and it is the
       highest priority available, pages are allocated on a round-robin
       basis between them.

```

This is not to be confused with _swappiness_.

---

<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:** [March 1, 2023, 1:52pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/12 "2023-03-01T13:52:17Z")

</div>

> [@MindTheGAAP](#):
>
> swap-priority

> swap-priority=  
> Controls the relative swap priority, a value between -1 and 32767. Higher numbers indicate higher priority.  
> If unset, 100 is used.

> 👁 [https://man.archlinux.org/man/zram-generator.conf.5](https://man.archlinux.org/man/zram-generator.conf.5)

---

<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, 2:12pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/13 "2023-03-01T14:12:55Z")

</div>

Would enabling ZRAM not slow down a system that already has more than enough ram, like I have 32gb of ram, Why would I need to enable ZRAM?

---

<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, 2:17pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/14 "2023-03-01T14:17:00Z")

</div>

> [@VolantesMagus](#):
>
> 32gb of ram

If you are not utilizing all your ram, you don’t need zram in the first place.

However, if your ram usage is shooting past 32gb, then zram will help. Keep in mind, if you make the zram size too large, it will probably backfire under higher load.

---

<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 1, 2023, 2:28pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/15 "2023-03-01T14:28:49Z")

</div>

> [@VolantesMagus](#):
>
> Why would I need to enable ZRAM?

Because running out of RAM is problematic unless you are running an OOM killer. In most cases, it will result in a a hard freeze.

The answer that most people don’t like to hear is that there is not a simple “right answer”. Whether to use a swap partition, a swap file, zswap, zram, no swap or some combination depends on the individual’s workload and hardware.

I will say that using zram is actually a pretty good default for most desktop use cases.

---

<div class="post-metadata">

**Author:** ![MindTheGAAP](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/mindthegaap/32/47060_2.png) [@MindTheGAAP](https://forum.endeavouros.com/u/MindTheGAAP)\
**Post date:** [March 1, 2023, 3:49pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/16 "2023-03-01T15:49:56Z")

</div>

Yes I just have one swap zram0 setup for 4GB. I have 16GB.

Btw do you have a YouTube channel where you did a video on zram? I remember a similar name.

Thanks for the tips

---

<div class="post-metadata">

**Author:** ![SearingSunrazeSmash](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/searingsunrazesmash/32/74433_2.png) [@SearingSunrazeSmash](https://forum.endeavouros.com/u/SearingSunrazeSmash)\
**Post date:** [March 1, 2023, 3:53pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/17 "2023-03-01T15:53:09Z")

</div>

> [@¿What is zram and how to install it?](https://forum.endeavouros.com/t/what-is-zram-and-how-to-install-it/26314/4):
>
> Please see this [Guide.](https://m.youtube.com/watch?v=7YyGSgZTH8Q) Made by @flyingcakes. All thanks to him.

---

<div class="post-metadata">

**Author:** ![MindTheGAAP](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/mindthegaap/32/47060_2.png) [@MindTheGAAP](https://forum.endeavouros.com/u/MindTheGAAP)\
**Post date:** [March 1, 2023, 4:22pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/18 "2023-03-01T16:22:15Z")

</div>

Yes, that’s the one. I remember watching it.

Great content for new users

---

<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:** [March 1, 2023, 5:06pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/19 "2023-03-01T17:06:40Z")

</div>

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 have 14 gigs, and I had situations where it wasn’t enough and the system slowed down a lot, even with a nvme ssd. But I guess, I will still need a regular swapfile.

Is lz4 the fastest?

---

<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:40pm UTC](https://forum.endeavouros.com/t/enabling-zram-in-endeavouros/37746/20 "2023-03-01T17:40:40Z")

</div>

> [@MindTheGAAP](#):
>
> Btw do you have a YouTube channel where you did a video on zram?

Yes.

However an obligatory note : the config format has changed after I made the video. As usual, the new config too is “readable”. Rest of the steps remain same.

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