You are not logged in.

#1 2026-04-22 04:49:37

imjiaoyuan
Member
Registered: 2025-11-24
Posts: 13

[solved]How to enable zswap under systemd?

As the title says,my system information is follows,wiki isn't tell me how to set


jiaoyuan:~ > cat /proc/swaps
Filename                                Type            Size            Used            Priority
jiaoyuan:~ > zgrep CONFIG_ZSWAP_DEFAULT_ON /proc/config.gz
CONFIG_ZSWAP_DEFAULT_ON=y
jiaoyuan:~ > cat /sys/module/zswap/parameters/enabled
N
jiaoyuan:~ > cat /proc/cmdline
root=PARTUUID=11434434-65bd-477e-b594-da90cc0c91c5 zswap.enabled=0 rootflags=subvol=@ rw rootfstype=btrfs
jiaoyuan:~ > sudo dmesg | grep zswap
[    0.000000] Command line: root=PARTUUID=11434434-65bd-477e-b594-da90cc0c91c5 zswap.enabled=0 rootflags=subvol=@ rw rootfstype=btrfs
[    0.055065] Kernel command line: root=PARTUUID=11434434-65bd-477e-b594-da90cc0c91c5 zswap.enabled=0 rootflags=subvol=@ rw rootfstype=btrfs
jiaoyuan:~ > cat /sys/module/zswap/parameters/enabled
N
jiaoyuan:~ >

Last edited by imjiaoyuan (2026-04-23 01:46:17)

Offline

#2 2026-04-22 05:34:25

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,461

Re: [solved]How to enable zswap under systemd?

1)zswap needs a real swap partition
2)zswap.enabled=0 in the kernel cmdline explicitely disables it.


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#3 2026-04-22 05:49:12

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,841

Re: [solved]How to enable zswap under systemd?

1)zswap needs a real swap partition

https://wiki.archlinux.org/title/Swap#Swap_file will do as well, but physical swap is mandatory. Do not try to use zswap along zram

Offline

#4 2026-04-22 06:00:03

imjiaoyuan
Member
Registered: 2025-11-24
Posts: 13

Re: [solved]How to enable zswap under systemd?

kokoko3k wrote:

1)zswap needs a real swap partition
2)zswap.enabled=0 in the kernel cmdline explicitely disables it.

how to finish step2?I use systemd but the wiki use grub

Offline

#5 2026-04-22 06:04:53

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,841

Re: [solved]How to enable zswap under systemd?

"grub" is a bootloader, "systemd" is a kitchen sink.
Iff you're using "systemd-boot", see https://wiki.archlinux.org/title/System … figuration

Offline

#6 2026-04-23 01:45:49

imjiaoyuan
Member
Registered: 2025-11-24
Posts: 13

Re: [solved]How to enable zswap under systemd?

seth wrote:

"grub" is a bootloader, "systemd" is a kitchen sink.
Iff you're using "systemd-boot", see https://wiki.archlinux.org/title/System … figuration

I slved it ,thanks very much

Offline

#7 2026-04-23 02:13:49

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,676

Re: [solved]How to enable zswap under systemd?

Perhaps you could post how you solved it so that this thread might be useful in the future for somebody with the same issue as you

Offline

#8 2026-04-23 02:45:20

imjiaoyuan
Member
Registered: 2025-11-24
Posts: 13

Re: [solved]How to enable zswap under systemd?

skunktrader wrote:

Perhaps you could post how you solved it so that this thread might be useful in the future for somebody with the same issue as you

good idea!

https://jiaoyuan.org/posts/2026-04-22-a … ckup-swap/

I post it on my blog, I finish it as follows:

Create an empty file
sudo truncate -s 0 /swapfile

Set the no‑COW attribute
sudo chattr +C /swapfile

Allocate the desired size
sudo fallocate -l 16G /swapfile

Set correct permissions
sudo chmod 600 /swapfile

Format as swap
sudo mkswap /swapfile

Enable the swap file:

sudo swapon /swapfile
swapon --show

Add it to fstab:

echo '/swapfile none swap defaults 0 0' | sudo tee -a /etc/fstab

Now the physical swap space is ready. Next, add kernel boot parameters. I use systemd‑boot with a UKI, so kernel parameters are configured by editing the kernel command line file /etc/kernel/cmdline. The contents of this file are read by mkinitcpio and packed into the UKI:

sudo nano /etc/kernel/cmdline

Append the zswap parameters at the end:

root=PARTUUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx rw loglevel=3 zswap.enabled=1 zswap.compressor=zstd zswap.max_pool_percent=25

Finally, pack the new parameters from /etc/kernel/cmdline into the kernel:

sudo mkinitcpio -P

Reboot. Verify that zswap is enabled:

jiaoyuan:~ > cat /sys/module/zswap/parameters/enabled
Y

jiaoyuan:~ > free -h
total used free shared buff/cache available
Mem: 30Gi 8.0Gi 17Gi 2.1Gi 7.8Gi 22Gi
Swap: 15Gi 0B 15Gi

Offline

Board footer

Powered by FluxBB