Is ZSWAP enabled by default?

Hello!

I just configured ZRAM yesterday for the first time (thank you AI for making RAM prices so unaffordable for everyone :pensive_face:) but I just found out today that ZSWAP is also already enabled by default and I had to add zswap.enabled=0 in grub after GRUB_CMDLINE_LINUX_DEFAULT= to disable it. I guess it’s better not to have them both enabled at the same time.

My question is: Is ZSWAP actually enabled by default or did I accidentally enable it somehow? and isn’t ZRAM a better alternative generally speaking?

If anyone can shed some light on this I would be grateful.

I keep discovering new things about Manjaro all the time. :blush:

zswap is enabled by default.

zswap is better than zram, as the swapping is managed by the kernel. zswap compresses in RAM (like zram), but it is much more effective at managing pages, whether it be removing them from RAM, or swapping between the RAM & the swap partition or swapfile.

A reply I wrote earlier this year:

Oh interesting… i’ll fully read up on the link you provided a bit later. Thanks!

The strange thing is that I had setup a swap file before… I didn’t even know I had ZSWAP enabled. But my system kept swapping RAM to the swap file on disc instead of compressing or swapping to RAM.

After I enabled ZRAM it now compresses the SWAP to RAM instead of writing it to disc like it did before. Why didn’t ZSWAP work before? is there any other settings I need to implement to enable or configure it?

(Edit: I prefer avoiding writing to the disc swap file as much as possible because of long term wear on the drive, the swap size usually goes up 2-4GB)

You can check while booted a default Manjaro kernel

 $ zcat /proc/config.gz | grep -i ZSWAP
CONFIG_ZSWAP=y
CONFIG_ZSWAP_DEFAULT_ON=y
CONFIG_ZSWAP_SHRINKER_DEFAULT_ON=y
# CONFIG_ZSWAP_COMPRESSOR_DEFAULT_DEFLATE is not set
# CONFIG_ZSWAP_COMPRESSOR_DEFAULT_LZO is not set
# CONFIG_ZSWAP_COMPRESSOR_DEFAULT_842 is not set
# CONFIG_ZSWAP_COMPRESSOR_DEFAULT_LZ4 is not set
# CONFIG_ZSWAP_COMPRESSOR_DEFAULT_LZ4HC is not set
CONFIG_ZSWAP_COMPRESSOR_DEFAULT_ZSTD=y
CONFIG_ZSWAP_COMPRESSOR_DEFAULT="zstd"
# Zsmalloc is a common backend allocator for zswap & zram

More information in the Arch Wiki

I don’t think you can actually see how much RAM zswap is using for swapped pages, as the swapped pages in RAM are stored as compressed cache data. So, if you run the command free -h, the zswap usage will be included in the buff/cache section:

❯ free -h
               total        used        free      shared  buff/cache   available
Mem:            28Gi       7.7Gi       674Mi       561Mi        19Gi        20Gi
Swap:          8.0Gi        56Ki       8.0Gi

The amount shown in Swap would only appear if the device also has a swap partition/file enabled, and that figure only includes pages that have been swapped out by zswap from compressed RAM to the swap partition/file.

This also means that a user who has no swap partition will still be storing compressed swap pages in RAM (as long as zswap is enabled).

Edit 2026-10-11T01:15:00Z: Having done some more reading online, it seems I was incorrect in my assumption that zswap still works without a physical swap partition or file. zswap is enabled in the kernel by default, but it requires physical swap to actually be active:

The default maximum amount of RAM the kernel allocates for zswap is 20%.

You can check your current zswap parameters by running the following command:

grep -r . /sys/module/zswap/parameters/

Edit: Also, this article from yesterday shows more improvements are coming to zswap:

Sadly it seemed a bit too eager to write to the swap file, even when I still had enough RAM left there would be 1-3GB in swap (I also have /proc/sys/vm/swappiness set to a value of 1 which is the lowest value that doesn’t make my computer crash when oom)

After disabling ZSWAP and enabling ZRAM I tried a few times to put the memory under pressure and it would compress/swap to RAM and leave the swap file empty, which is the “ideal case” scenario for me.

I am interested in trying ZSWAP again in the future but I guess for now i’ll stick to ZRAM to reduce/avoid swap to file writes. :cross_mark::page_facing_up::writing_hand:t2:

Very good timing and relevancy for our current discussion! :blush:

Phoronix is amazing. One of the best linux related news websites out there. :+1:t2:

That is a kernel i want as soon as it becomes ready.