Why can't my Garuda Linux set the zswap.enabled=1 kernel parameter in GRUB?

Why can’t my Garuda Linux set the zswap.enabled=1 kernel parameter in GRUB?

However, the command ‘echo 1 > /sys/module/zswap/parameters/enabled’ runs quite smoothly.

I just want to run a game server,like Minecraft server or another game server on my computer.

In my EndeavourOS, I set up ZRAM after setting up Swap and ZSwap manually first, and then using the manual method provided by ArchWiki_Zram#Manually,and after organizing the sequential order, they both work very well!

In the end,I sincerely hope that in the next update, ZSwap will start with the indicated kernel parameters.

My GRUB settings are as follows:

GRUB_CMDLINE_LINUX_DEFAULT='splash loglevel=3 zswap.enabled=1 zswap.max_pool_percent=90 zswap.accept_threshold_percent=80 sysctl.vm.swappiness=20'

# zgrep CONFIG_ZSWAP_DEFAULT_ON /proc/config.gz
CONFIG_ZSWAP_DEFAULT_ON=y
# grep -r . /sys/module/zswap/parameters/
/sys/module/zswap/parameters/enabled:N
/sys/module/zswap/parameters/shrinker_enabled:Y
/sys/module/zswap/parameters/max_pool_percent:90
/sys/module/zswap/parameters/compressor:zstd
/sys/module/zswap/parameters/zpool:zsmalloc
/sys/module/zswap/parameters/accept_threshold_percent:80
# grep -r . /sys/kernel/debug/zswap
/sys/kernel/debug/zswap/same_filled_pages:0
/sys/kernel/debug/zswap/stored_pages:0
/sys/kernel/debug/zswap/pool_total_size:0
/sys/kernel/debug/zswap/written_back_pages:0
/sys/kernel/debug/zswap/reject_compress_poor:0
/sys/kernel/debug/zswap/reject_compress_fail:0
/sys/kernel/debug/zswap/reject_kmemcache_fail:0
/sys/kernel/debug/zswap/reject_alloc_fail:0
/sys/kernel/debug/zswap/reject_reclaim_fail:0
/sys/kernel/debug/zswap/pool_limit_hit:0

# dmesg | grep -i zswap
[    0.000000] Command line: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen root=UUID=a3560f26-be53-4f0a-b3b3-3e4f91226299rw rootflags=subvol=@ splash loglevel=3 zswap.enabled=1 zswap.max_pool_percent=90 zswap.accept_threshold_percent=80 sysctl.vm.swappiness=20 ibt=off
[    0.019798] Kernel command line: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen root=UUID=a3560f26-be53-4f0a-b3b3-3e4f91226299 rw rootflags=subvol=@ splash loglevel=3 zswap.enabled=1 zswap.max_pool_percent=90 zswap.accept_threshold_percent=80 sysctl.vm.swappiness=20 ibt=off
[    0.537192] zswap: loaded using pool zstd/zsmalloc
$ garuda-inxi
System:
Kernel: 6.11.4-zen2-1-zen arch: x86_64 bits: 64 compiler: gcc v: 14.2.1
clocksource: tsc avail: acpi_pm
parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
root=UUID=a3560f26-be53-4f0a-b3b3-3e4f91226299 rw rootflags=subvol=@
splash loglevel=3 zswap.enabled=1 zswap.max_pool_percent=90
zswap.accept_threshold_percent=80 sysctl.vm.swappiness=20 ibt=off
Desktop: KDE Plasma v: 6.2.1 tk: Qt v: N/A info: frameworks v: 6.7.0
wm: kwin_wayland vt: 1 dm: SDDM Distro: Garuda base: Arch Linux
Machine:
Type: Laptop System: MECHREVO product: Jiaolong16S Series GM6XG0X
v: Standard serial: <superuser required>
Mobo: MECHREVO model: GM6XG0X v: Standard serial: <superuser required>
part-nu: 0001 uuid: <superuser required> UEFI: American Megatrends LLC.
v: N.1.24MRO14 date: 10/16/2023
Battery:
ID-1: BAT0 charge: 62.3 Wh (100.0%) condition: 62.3/62.3 Wh (100.0%)
volts: 16.5 min: 15.2 model: standard type: Li-ion serial: <filter>
status: full
CPU:
Info: model: AMD Ryzen 7 7840H w/Radeon 780M Graphics bits: 64 type: MT MCP
arch: Zen 4 gen: 4 level: v4 note: check built: 2022+ process: TSMC n5 (5nm)
family: 0x19 (25) model-id: 0x74 (116) stepping: 1 microcode: 0xA704103
Topology: cpus: 1x dies: 1 clusters: 1 cores: 8 threads: 16 tpc: 2
smt: enabled cache: L1: 512 KiB desc: d-8x32 KiB; i-8x32 KiB L2: 8 MiB
desc: 8x1024 KiB L3: 16 MiB desc: 1x16 MiB
Speed (MHz): avg: 1098 min/max: 400/5137 boost: enabled scaling:
driver: amd-pstate-epp governor: powersave cores: 1: 1098 2: 1098 3: 1098
4: 1098 5: 1098 6: 1098 7: 1098 8: 1098 9: 1098 10: 1098 11: 1098 12: 1098
13: 1098 14: 1098 15: 1098 16: 1098 bogomips: 121360
Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
Vulnerabilities: <filter>
Graphics:
Device-1: NVIDIA AD107M [GeForce RTX 4060 Max-Q / Mobile]
vendor: AIstone Global driver: nvidia v: 560.35.03
alternate: nouveau,nvidia_drm non-free: 550.xx+
status: current (as of 2024-09) arch: Lovelace code: AD1xx
process: TSMC n4 (5nm) built: 2022+ pcie: gen: 4 speed: 16 GT/s lanes: 8
ports: active: none off: eDP-1 empty: DP-1,HDMI-A-1 bus-ID: 01:00.0
chip-ID: 10de:28a0 class-ID: 0300
Device-2: Advanced Micro Devices [AMD/ATI] Phoenix1 vendor: AIstone Global
driver: amdgpu v: kernel arch: RDNA-3 code: Phoenix process: TSMC n4 (4nm)
built: 2023+ pcie: gen: 4 speed: 16 GT/s lanes: 16 ports: active: none
empty: DP-2, DP-3, DP-4, DP-5, Writeback-1, eDP-2 bus-ID: 07:00.0
chip-ID: 1002:15bf class-ID: 0300 temp: 49.0 C
Device-3: SunplusIT HD Webcam driver: uvcvideo type: USB rev: 2.0
speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 1-3:4 chip-ID: 2b7e:b651
class-ID: 0e02 serial: <filter>
Display: wayland server: X.org v: 1.21.1.13 with: Xwayland v: 24.1.3
compositor: kwin_wayland driver: X: loaded: amdgpu,nvidia
unloaded: modesetting,nouveau alternate: fbdev,nv,vesa dri: radeonsi
gpu: nvidia,amdgpu display-ID: 0
Monitor-1: eDP-1 res: 1707x1067 size: N/A modes: N/A
API: EGL v: 1.5 hw: drv: nvidia drv: amd radeonsi platforms: device: 0
drv: nvidia device: 2 drv: radeonsi device: 3 drv: swrast gbm: drv: nvidia
surfaceless: drv: nvidia wayland: drv: nvidia x11: drv: nvidia
inactive: device-1
API: OpenGL v: 4.6.0 compat-v: 4.5 vendor: nvidia mesa v: 560.35.03
glx-v: 1.4 direct-render: yes renderer: NVIDIA GeForce RTX 4060 Laptop
GPU/PCIe/SSE2 memory: 7.81 GiB display-ID: :1.0
API: Vulkan v: 1.3.295 layers: 11 device: 0 type: discrete-gpu name: NVIDIA
GeForce RTX 4060 Laptop GPU driver: nvidia v: 560.35.03
device-ID: 10de:28a0 surfaces: xcb,xlib,wayland device: 1
type: integrated-gpu name: AMD Radeon 780M (RADV GFX1103_R1)
driver: mesa radv v: 24.2.5-arch1.1 device-ID: 1002:15bf
surfaces: xcb,xlib,wayland device: 2 type: cpu name: llvmpipe (LLVM
18.1.8 256 bits) driver: mesa llvmpipe v: 24.2.5-arch1.1 (LLVM 18.1.8)
device-ID: 10005:0000 surfaces: xcb,xlib,wayland
Audio:
Device-1: NVIDIA AD107 High Definition Audio vendor: AIstone Global
driver: snd_hda_intel v: kernel pcie: gen: 4 speed: 16 GT/s lanes: 8
bus-ID: 01:00.1 chip-ID: 10de:22be class-ID: 0403
Device-2: Advanced Micro Devices [AMD] ACP/ACP3X/ACP6x Audio Coprocessor
vendor: AIstone Global driver: snd_pci_ps v: kernel alternate: snd_pci_acp3x,
snd_rn_pci_acp3x, snd_pci_acp5x, snd_pci_acp6x, snd_acp_pci,
snd_rpl_pci_acp6x, snd_sof_amd_renoir, snd_sof_amd_rembrandt,
snd_sof_amd_vangogh, snd_sof_amd_acp63 pcie: gen: 4 speed: 16 GT/s
lanes: 16 bus-ID: 07:00.5 chip-ID: 1022:15e2 class-ID: 0480
Device-3: Advanced Micro Devices [AMD] Family 17h/19h HD Audio
vendor: AIstone Global driver: snd_hda_intel v: kernel pcie: gen: 4
speed: 16 GT/s lanes: 16 bus-ID: 07:00.6 chip-ID: 1022:15e3 class-ID: 0403
API: ALSA v: k6.11.4-zen2-1-zen status: kernel-api tools: N/A
Server-1: PipeWire v: 1.2.5 status: active with: 1: pipewire-pulse
status: active 2: wireplumber status: active 3: pipewire-alsa type: plugin
4: pw-jack type: plugin tools: pactl,pw-cat,pw-cli,wpctl
Network:
Device-1: Realtek RTL8111/8168/8211/8411 PCI Express Gigabit Ethernet
vendor: AIstone Global driver: r8169 v: kernel pcie: gen: 1 speed: 2.5 GT/s
lanes: 1 port: e000 bus-ID: 03:00.0 chip-ID: 10ec:8168 class-ID: 0200
IF: enp3s0 state: up speed: 1000 Mbps duplex: full mac: <filter>
Device-2: MEDIATEK MT7921K Wi-Fi 6E 80MHz driver: mt7921e v: kernel pcie:
gen: 2 speed: 5 GT/s lanes: 1 bus-ID: 04:00.0 chip-ID: 14c3:0608
class-ID: 0280
IF: wlp4s0 state: down mac: <filter>
IF-ID-1: nekoray-tun state: unknown speed: 10000 Mbps duplex: full
mac: N/A
Info: services: NetworkManager, systemd-timesyncd, wpa_supplicant
Bluetooth:
Device-1: MediaTek Wireless_Device driver: btusb v: 0.8 type: USB rev: 2.1
speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 1-5:5 chip-ID: 0e8d:0608
class-ID: e001 serial: <filter>
Report: btmgmt ID: hci0 rfk-id: 0 state: down bt-service: enabled,running
rfk-block: hardware: no software: yes address: <filter> bt-v: 5.2 lmp-v: 11
status: discoverable: no pairing: no
Drives:
Local Storage: total: 2.79 TiB used: 1.04 TiB (37.1%)
SMART Message: Unable to run smartctl. Root privileges required.
ID-1: /dev/nvme0n1 maj-min: 259:0 model: TOPMORE Gemini size: 1.86 TiB
block-size: physical: 512 B logical: 512 B speed: 63.2 Gb/s lanes: 4
tech: SSD serial: <filter> fw-rev: 1.W.F.G2 temp: 38.9 C scheme: MBR
ID-2: /dev/nvme1n1 maj-min: 259:5 vendor: Hynix model: YMTC PC300-1TB-B
size: 953.87 GiB block-size: physical: 512 B logical: 512 B speed: 63.2 Gb/s
lanes: 4 tech: SSD serial: <filter> fw-rev: YM0500C6 temp: 52.9 C
scheme: GPT
Partition:
ID-1: / raw-size: 1012 GiB size: 1012 GiB (100.00%) used: 319.73 GiB (31.6%)
fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
ID-2: /boot/efi raw-size: 100 MiB size: 96 MiB (96.00%)
used: 50.9 MiB (53.0%) fs: vfat dev: /dev/nvme1n1p1 maj-min: 259:6
ID-3: /home raw-size: 1012 GiB size: 1012 GiB (100.00%)
used: 319.73 GiB (31.6%) fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
ID-4: /var/log raw-size: 1012 GiB size: 1012 GiB (100.00%)
used: 319.73 GiB (31.6%) fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
ID-5: /var/tmp raw-size: 1012 GiB size: 1012 GiB (100.00%)
used: 319.73 GiB (31.6%) fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
Swap:
Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default) zswap: no
ID-1: swap-1 type: zram size: 14.84 GiB used: 0 KiB (0.0%) priority: 100
comp: zstd avail: lzo,lzo-rle,lz4,lz4hc,842 max-streams: 16 dev: /dev/zram0
ID-2: swap-2 type: partition size: 64 GiB used: 0 KiB (0.0%) priority: 5
dev: /dev/nvme0n1p1 maj-min: 259:1
Sensors:
System Temperatures: cpu: 56.0 C mobo: 50.0 C gpu: amdgpu temp: 51.0 C
Fan Speeds (rpm): N/A
Info:
Memory: total: 16 GiB note: est. available: 14.84 GiB used: 6.19 GiB (41.7%)
Processes: 422 Power: uptime: 1h 1m states: freeze,mem,disk
suspend: s2idle wakeups: 0 hibernate: platform avail: shutdown, reboot,
suspend, test_resume image: 5.89 GiB services: org_kde_powerdevil,
power-profiles-daemon, upowerd Init: systemd v: 256 default: graphical
tool: systemctl
Packages: pm: pacman pkgs: 1811 libs: 477 tools: octopi,paru Compilers:
gcc: 14.2.1 Shell: garuda-inxi default: fish v: 3.7.1 running-in: konsole
inxi: 3.3.36
Garuda (2.6.26-1):
System install date:     2024-10-22
Last full system update: 2024-10-22
Is partially upgraded:   No
Relevant software:       snapper NetworkManager dracut nvidia-dkms
Windows dual boot:       Probably (Run as root to verify)
Failed units:            systemd-vconsole-setup.service

There is a systemd-tmpfiles config (ArchWiki - systemd-tmpfiles) which has been set up to disable zswap. It is this file here:

/usr/lib/tmpfiles.d/disable-zswap.conf

Each time the tmpfiles.d directory is read, it writes a 0 to /sys/module/zswap/parameters/enabled.

w /sys/module/zswap/parameters/enabled - - - - 0

This is done on purpose, because Garuda Linux uses zram by default. Zswap interferes with zram (you should use one or the other, not both).

zram - ArchWiki

Note:

[…]

  • If the related zswap kernel feature remains enabled, it will prevent zram from being used effectively. This is because zswap functions as a swap cache in front of zram, intercepting and compressing evicted memory pages before they can reach zram. Despite the output of zramctl(8), most of zswap is unused in this circumstance. Therefore, it’s recommended to permanently disable zswap using the kernel parameter or sysfs setting before starting.

If you want to overwrite this default (even though zram will not work correctly anymore), you can copy the config from /usr/lib/tmpfiles.d/disable-zswap.conf to /etc/tmpfiles.d/ and change the 0 to a 1 in your copy.

I hope that helps, welcome to the community @7XKR. :wave:

10 Likes

Thank you for your help!
Based on the information you provided, I made a bold attempt to reboot the system after removing the disable-zswap.conf file and it worked fine, thanks!

Be aware, the file will be automatically restored every time garuda-common-settings is updated. If you want to permanently change the behavior, you need to properly overwrite the file in /etc/tmpfiles.d like I mentioned above.

3 Likes

OK,thanks!!!

**Excuse me!**But why set the swappiness parameter to 133, wouldn’t that be huge?
I use ‘systemd-analyze cat-config tmpfiles.d’ to display the effective config,but I can’t find any parameter for swappiness.

If using zram, higher swappiness values are recommended for taking full advantage of the fact that IO against the swap device is about twice as fast as IO from the filesystem. See this related paragraph from the kernel docs:

https://docs.kernel.org/admin-guide/sysctl/vm.html

For in-memory swap, like zram or zswap, as well as hybrid setups that have swap on faster devices than the filesystem, values beyond 100 can be considered. For example, if the random IO against the swap device is on average 2x faster than IO from the filesystem, swappiness should be 133 (x + 2x = 200, 2x = 133.33).

133 is fairly modest in fact; some recommendations suggest there may be a benefit using even higher values. Pop_OS uses 180, for example.

See also the relevant ArchWiki article, which suggests swappiness should be around 200 when using zram:

https://wiki.archlinux.org/title/Zram#Optimizing_swap_on_zram

On a system with a hard drive, random I/O against the zswap device would be orders of magnitude faster than I/O against the filesystem, so swappiness should be ~200. Even on a system with a fast SSD, a high swappiness value may be ideal.


Swappiness isn’t set in a systemd-tmpfiles config, it is set in a sysctl configuration drop-in.

/usr/lib/sysctl.d/99-sysctl-garuda.conf
# The swappiness sysctl parameter represents the kernel's preference (or avoidance) of swap space. Swappiness can have a value between 0 and 200, the default value is 60.
# A low value causes the kernel to avoid swapping, a higher value causes the kernel to try to use swap space. Using a low value on sufficient memory is known to improve responsiveness on many systems.
vm.swappiness=133

# Disable NMI watchdog: This action will speed up your boot and shutdown, because one less module is loaded. Additionally disabling watchdog timers increases performance and lowers power consumption
kernel.nmi_watchdog = 0

# Enable the sysctl setting kernel.unprivileged_userns_clone to allow normal users to run unprivileged containers.
kernel.unprivileged_userns_clone=1

# To hide any kernel messages from the console
kernel.printk = 3 3 3 3

# the key combination of Alt+SysRq+<b/e/f/s/u> will result in Magic SysRQ invocation
kernel.sysrq=1

Similar to the systemd-tmpfiles config, if you directly modify this file it will be overwritten every time the package which owns it (garuda-common-settings) is updated or reinstalled. If you want to adjust the swappiness value, you should copy the file to /etc/sysctl.d/ and make your changes there.

5 Likes

You are like an angel sent from God, how thankful for your friendly help!

3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.