# Swap. what is recommended

**URL:** <https://forum.endeavouros.com/t/swap-what-is-recommended/37132>\
**Category:** EndeavourOS installation\
**Created:** [February 11, 2023, 11:10am UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132 "2023-02-11T11:10:15Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![swh](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/swh/32/95303_2.png) [@swh](https://forum.endeavouros.com/u/swh)\
**Post date:** [February 11, 2023, 11:10am UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/1 "2023-02-11T11:10:15Z")

</div>

hey all, on a fresh :enos: install on `ext4` do you recommend a swap file or a swap partition.  
what are pro’s and con’s ?

i should urgently reinstall my desktop, i have already backed up everything i want to use again. just have these questions about swap

This is how it looks now.

```auto
❯ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 931,5G 0 disk 
└─sda1 8:1 0 931,5G 0 part /srv/nfsv4/Share
                                      /run/media/swh/Mediathek
sdb 8:16 0 931,5G 0 disk /srv/nfsv4/Filme
                                      /run/media/swh/Stuff
sdc 8:32 0 223,6G 0 disk 
└─sdc1 8:33 0 223,6G 0 part /run/media/swh/SDD
sr0 11:0 1 1024M 0 rom  
nvme0n1 259:0 0 232,9G 0 disk 
├─nvme0n1p1 259:1 0 300M 0 part /boot/efi
└─nvme0n1p2 259:2 0 232,6G 0 part /

```

i plan to mount the home partition in an internal `ssd`

---

<div class="post-metadata">

**Author:** ![LamnaNasus](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/lamnanasus/32/10804_2.png) [@LamnaNasus](https://forum.endeavouros.com/u/LamnaNasus)\
**Post date:** [February 11, 2023, 11:18am UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/2 "2023-02-11T11:18:12Z")

</div>

You could check out a third alternative, Zram.  
There are probably other advantages, but I use it mainly because of the ease and simplicity. No need to mess around with partitions or swap files.

> [@¿What is zram and how to install it?](https://forum.endeavouros.com/t/what-is-zram-and-how-to-install-it/26314):
>
> The [zram](https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html) kernel module (previously called compcache ) provides a compressed block device in RAM. If you use it as swap device, the RAM can hold much more information but uses more CPU. Still, it is much quicker than swapping to a hard drive. If a system often falls back to swap, this could improve responsiveness. Using zram is also a good way to reduce disk read/write cycles due to swap on SSDs. From my personal experience, it is one of the best things I have discovered using linux, the differe…

---

<div class="post-metadata">

**Author:** ![swh](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/swh/32/95303_2.png) [@swh](https://forum.endeavouros.com/u/swh)\
**Post date:** [February 11, 2023, 11:44am UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/3 "2023-02-11T11:44:56Z")

</div>

> [@LamnaNasus](#):
>
> You could check out a third alternative, Zram.

Thank you! I did not know about this possibility. one never stops learning 😉 this looks like a simple but effective solution to me  
if i understand correctly i install zram after installation.

---

<div class="post-metadata">

**Author:** ![LamnaNasus](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/lamnanasus/32/10804_2.png) [@LamnaNasus](https://forum.endeavouros.com/u/LamnaNasus)\
**Post date:** [February 11, 2023, 11:46am UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/4 "2023-02-11T11:46:16Z")

</div>

Yeah. You choose “no swap” during the EOS installation. When you’re up and running you just install the package and write the config, as described in the tutorial.

---

<div class="post-metadata">

**Author:** ![swh](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/swh/32/95303_2.png) [@swh](https://forum.endeavouros.com/u/swh)\
**Post date:** [February 11, 2023, 11:49am UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/5 "2023-02-11T11:49:02Z")

</div>

i will try that. thanks a lot

---

<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:** [February 11, 2023, 12:14pm UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/6 "2023-02-11T12:14:05Z")

</div>

I prefer a swapfile because of flexibility. But I use zram as well so that I have

```auto
NAME TYPE SIZE USED PRIO
/swap/swapfile file 18G 0B -2
/dev/zram0 partition 7.5G 2G 100

```

where my main memory is 16 GB.

---

<div class="post-metadata">

**Author:** ![swh](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/swh/32/95303_2.png) [@swh](https://forum.endeavouros.com/u/swh)\
**Post date:** [February 11, 2023, 12:29pm UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/7 "2023-02-11T12:29:15Z")

</div>

My main memory is 16gb like yours. I will definitely choose ‘no swap’ during installation. I then install zram  
i just notice that the pc, as it is configured now, is completely busy as soon as i do any video editing with handbrake  
now i use a swap partition with 8gb

---

<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 11, 2023, 3:46pm UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/8 "2023-02-11T15:46:41Z")

</div>

> [@manfredlotz](#):
>
> I prefer a swapfile because of flexibility. But I use zram as well so that I have

In that situation, wouldn’t zswap be a better choice?

---

<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:** [February 11, 2023, 4:46pm UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/9 "2023-02-11T16:46:50Z")

</div>

> [@dalto](#):
>
> In that situation, wouldn’t zswap be a better choice?

Thanks for asking. I have to admit that I had started with `zram` alone and then later having added a swapfile. Now, when thinking deeper you might be right as `zswap` seems to be better when swapfile is used additionally.

So, I have to re-evaluate

---

<div class="post-metadata">

**Author:** ![anon11595408](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/f1d935/32.png) [@anon11595408](https://forum.endeavouros.com/u/anon11595408)\
**Post date:** [February 11, 2023, 5:10pm UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/10 "2023-02-11T17:10:38Z")

</div>

It all depends on the amount of physical RAM one has at hands. For 16GB and more, I would always recommend using Zram or Zswap, respectively.

---

<div class="post-metadata">

**Author:** ![Christopher67](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/christopher67/32/20118_2.png) [@Christopher67](https://forum.endeavouros.com/u/Christopher67)\
**Post date:** [February 11, 2023, 6:58pm UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/11 "2023-02-11T18:58:19Z")

</div>

[https://chrisdown.name/2018/01/02/in-defence-of-swap.html](https://chrisdown.name/2018/01/02/in-defence-of-swap.html)

👍🏼

---

<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:** [February 11, 2023, 7:11pm UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/12 "2023-02-11T19:11:18Z")

</div>

When looking at `zswap` it seems that when enabled

- `swapon` doesn’t show it
- the only information about its parameters seems to be something like `grep -R . /sys/module/zswap/parameters`
- the only information about its activity seems to be something like `grep -R . /sys/kernel/debug/zswap/`

Is this true?

---

<div class="post-metadata">

**Author:** ![anon11595408](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/f1d935/32.png) [@anon11595408](https://forum.endeavouros.com/u/anon11595408)\
**Post date:** [February 11, 2023, 7:16pm UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/13 "2023-02-11T19:16:42Z")

</div>

Try out `swapon --show`

✌

---

<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:** [February 11, 2023, 7:17pm UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/14 "2023-02-11T19:17:25Z")

</div>

`swapon --show` doesn’t make a difference

---

<div class="post-metadata">

**Author:** ![anon11595408](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/f1d935/32.png) [@anon11595408](https://forum.endeavouros.com/u/anon11595408)\
**Post date:** [February 11, 2023, 7:18pm UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/15 "2023-02-11T19:18:32Z")

</div>

`dmesg | grep zswap` ?

---

<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:** [February 11, 2023, 7:19pm UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/16 "2023-02-11T19:19:15Z")

</div>

This shows

```auto
 dmesg | grep zswap
[0.623013] zswap: loaded using pool lz4/z3fold

```

---

<div class="post-metadata">

**Author:** ![anon11595408](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/f1d935/32.png) [@anon11595408](https://forum.endeavouros.com/u/anon11595408)\
**Post date:** [February 11, 2023, 7:20pm UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/17 "2023-02-11T19:20:15Z")

</div>

And…

`dmesg | grep swap`

My current VM shows this:

> **dmesg | grep swap**
>
> [0.144028] Spectre V1 : Mitigation: usercopy/swapgs barriers and \_\_user pointer sanitization  
> [0.917340] zswap: loaded using pool lz4/z3fold  
> [33.242568] Adding 4343804k swap on /dev/sda5. Priority:-2 extents:1 across:4343804k FS

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

On bare-metal I keep using [Zram](https://wiki.archlinux.org/title/Zram).

---

<div class="post-metadata">

**Author:** ![LamnaNasus](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/lamnanasus/32/10804_2.png) [@LamnaNasus](https://forum.endeavouros.com/u/LamnaNasus)\
**Post date:** [February 11, 2023, 7:24pm UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/18 "2023-02-11T19:24:23Z")

</div>

@swh

PS:

Some people use zram in combination with disk-based swap, and some people use zram exclusively.

Personally, I’ve never encountered situations where disk based swap was needed beyond zram. If you encounter it, it should be easy enough to set up a swap file.

---

<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:** [February 11, 2023, 7:27pm UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/19 "2023-02-11T19:27:56Z")

</div>

```auto
 dmesg | grep swap
[0.191318] Spectre V1 : Mitigation: usercopy/swapgs barriers and __user pointer sanitization
[0.623013] zswap: loaded using pool lz4/z3fold
[10.654784] Adding 18874364k swap on /swap/swapfile. Priority:-2 extents:5 across:544473088k FS

```

I think my answer to my question above about getting information regarding zswap active settings and statistics seems to be reading `/sys/module/zswap/parameters/*` resp. `/sys/kernel/debug/zswap/`.

This means that if I want to have a command line interface I could write a script or program to deal with these directory contents.

---

<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:** [February 11, 2023, 7:28pm UTC](https://forum.endeavouros.com/t/swap-what-is-recommended/37132/20 "2023-02-11T19:28:18Z")

</div>

> [@manfredlotz](#):
>
> When looking at `zswap` it seems that when enabled
> 
> - `swapon` doesn’t show it

I might be wrong but the way I understand zswap is that it isn’t really a swap “device” in the way a swap partition, a swap file or zram is. That might be the reason why it doesn’t show in `swapon -s`.

It is a kernel feature and is enabled by default so there is no need enabling it. However if one uses zram, it needs to be disabled.

[Next page](https://forum.endeavouros.com/t/swap-what-is-recommended/37132.md?page=2)
