Я настроил это дело наподобие https://wiki.archlinux.org/title/Improving_performance#Swap_on_zram_using_a_udev_rule , и на первый взгляд всё как и должно быть:
[root@hp15 ~]# uname -a
Linux hp15 5.4.17-2136.304.4.1.el8uek.x86_64 #2 SMP Tue Feb 8 11:54:24 PST 2022 x86_64 x86_64 x86_64 GNU/Linux
[root@hp15 ~]# cat /etc/oracle-release
Oracle Linux Server release 8.5
[root@hp15 ~]# cat /etc/modules-load.d/zram.conf
zram
[root@hp15 ~]# cat /etc/modprobe.d/zram.conf
options zram num_devices=4
[root@hp15 ~]# cat /etc/udev/rules.d/99-zram.rules
KERNEL=="zram0", ATTR{disksize}="3072M" RUN="/usr/sbin/mkswap /dev/zram0", TAG+="systemd"
KERNEL=="zram1", ATTR{disksize}="3072M" RUN="/usr/sbin/mkswap /dev/zram1", TAG+="systemd"
KERNEL=="zram2", ATTR{disksize}="3072M" RUN="/usr/sbin/mkswap /dev/zram2", TAG+="systemd"
KERNEL=="zram3", ATTR{disksize}="3072M" RUN="/usr/sbin/mkswap /dev/zram3", TAG+="systemd"
[root@hp15 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Feb 11 18:30:53 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=a2fde00b-13cd-4228-ac40-3ad995455d84 / ext4 defaults,discard 1 1
/dev/zram0 none swap defaults 0 0
/dev/zram1 none swap defaults 0 0
/dev/zram2 none swap defaults 0 0
/dev/zram3 none swap defaults 0 0
[root@hp15 ~]# lsmod | grep zram
zram 32768 0
[root@hp15 ~]# ls -l /dev/ | grep zram
brw-rw----. 1 root disk 252, 0 Feb 17 21:19 zram0
brw-rw----. 1 root disk 252, 1 Feb 17 21:19 zram1
brw-rw----. 1 root disk 252, 2 Feb 17 21:19 zram2
brw-rw----. 1 root disk 252, 3 Feb 17 21:19 zram3
Но как выяснилось, это нифига не работает:
[root@hp15 ~]# free -m
total used free shared buff/cache available
Mem: 15705 1418 12487 371 1800 13613
Swap: 0 0 0
[root@hp15 ~]# systemctl list-units --type swap --all
UNIT LOAD ACTIVE SUB DESCRIPTION
● dev-zram0.swap loaded failed failed /dev/zram0
● dev-zram1.swap loaded failed failed /dev/zram1
● dev-zram2.swap loaded failed failed /dev/zram2
● dev-zram3.swap loaded failed failed /dev/zram3
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
4 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
[root@hp15 ~]# systemctl status dev-zram0.swap
● dev-zram0.swap - /dev/zram0
Loaded: loaded (/etc/fstab; generated)
Active: failed (Result: exit-code) since Thu 2022-02-17 21:19:50 MSK; 5min ago
What: /dev/zram0
Docs: man:fstab(5)
man:systemd-fstab-generator(8)
Feb 17 21:19:50 hp15 systemd[1]: Activating swap /dev/zram0...
Feb 17 21:19:50 hp15 swapon[706]: swapon: /dev/zram0: read swap header failed
Feb 17 21:19:50 hp15 systemd[1]: dev-zram0.swap: Swap process exited, code=exited status=255
Feb 17 21:19:50 hp15 systemd[1]: dev-zram0.swap: Failed with result 'exit-code'.
Feb 17 21:19:50 hp15 systemd[1]: Failed to activate swap /dev/zram0.
[root@hp15 ~]# systemctl status dev-zram1.swap
● dev-zram1.swap - /dev/zram1
Loaded: loaded (/etc/fstab; generated)
Active: failed (Result: exit-code) since Thu 2022-02-17 21:19:50 MSK; 5min ago
What: /dev/zram1
Docs: man:fstab(5)
man:systemd-fstab-generator(8)
Feb 17 21:19:50 hp15 systemd[1]: Activating swap /dev/zram1...
Feb 17 21:19:50 hp15 swapon[700]: swapon: /dev/zram1: read swap header failed
Feb 17 21:19:50 hp15 systemd[1]: dev-zram1.swap: Swap process exited, code=exited status=255
Feb 17 21:19:50 hp15 systemd[1]: dev-zram1.swap: Failed with result 'exit-code'.
Feb 17 21:19:50 hp15 systemd[1]: Failed to activate swap /dev/zram1.
[root@hp15 ~]# systemctl status dev-zram2.swap
● dev-zram2.swap - /dev/zram2
Loaded: loaded (/etc/fstab; generated)
Active: failed (Result: exit-code) since Thu 2022-02-17 21:19:50 MSK; 5min ago
What: /dev/zram2
Docs: man:fstab(5)
man:systemd-fstab-generator(8)
Feb 17 21:19:50 hp15 systemd[1]: Activating swap /dev/zram2...
Feb 17 21:19:50 hp15 swapon[702]: swapon: /dev/zram2: read swap header failed
Feb 17 21:19:50 hp15 systemd[1]: dev-zram2.swap: Swap process exited, code=exited status=255
Feb 17 21:19:50 hp15 systemd[1]: dev-zram2.swap: Failed with result 'exit-code'.
Feb 17 21:19:50 hp15 systemd[1]: Failed to activate swap /dev/zram2.
[root@hp15 ~]# systemctl status dev-zram3.swap
● dev-zram3.swap - /dev/zram3
Loaded: loaded (/etc/fstab; generated)
Active: failed (Result: exit-code) since Thu 2022-02-17 21:19:50 MSK; 5min ago
What: /dev/zram3
Docs: man:fstab(5)
man:systemd-fstab-generator(8)
Feb 17 21:19:50 hp15 systemd[1]: Activating swap /dev/zram3...
Feb 17 21:19:50 hp15 swapon[699]: swapon: /dev/zram3: read swap header failed
Feb 17 21:19:50 hp15 systemd[1]: dev-zram3.swap: Swap process exited, code=exited status=255
Feb 17 21:19:50 hp15 systemd[1]: dev-zram3.swap: Failed with result 'exit-code'.
Feb 17 21:19:50 hp15 systemd[1]: Failed to activate swap /dev/zram3.
Что любопытно, при ручной активации позже всё срабатывает как надо:
[root@hp15 ~]# swapon /dev/zram0
[root@hp15 ~]# swapon /dev/zram1
[root@hp15 ~]# swapon /dev/zram2
[root@hp15 ~]# swapon /dev/zram3
[root@hp15 ~]# free -m
total used free shared buff/cache available
Mem: 15705 1428 12510 337 1767 13637
Swap: 12287 0 12287
[root@hp15 ~]# systemctl list-units --type swap --all
UNIT LOAD ACTIVE SUB DESCRIPTION
dev-zram0.swap loaded active active /dev/zram0
dev-zram1.swap loaded active active /dev/zram1
dev-zram2.swap loaded active active /dev/zram2
dev-zram3.swap loaded active active /dev/zram3
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
4 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
[root@hp15 ~]# systemctl status dev-zram0.swap
● dev-zram0.swap - /dev/zram0
Loaded: loaded (/etc/fstab; generated)
Active: active (Result: exit-code) since Thu 2022-02-17 21:26:43 MSK; 23s ago
What: /dev/zram0
Docs: man:fstab(5)
man:systemd-fstab-generator(8)
[root@hp15 ~]# systemctl status dev-zram1.swap
● dev-zram1.swap - /dev/zram1
Loaded: loaded (/etc/fstab; generated)
Active: active (Result: exit-code) since Thu 2022-02-17 21:26:45 MSK; 24s ago
What: /dev/zram1
Docs: man:fstab(5)
man:systemd-fstab-generator(8)
[root@hp15 ~]# systemctl status dev-zram2.swap
● dev-zram2.swap - /dev/zram2
Loaded: loaded (/etc/fstab; generated)
Active: active (Result: exit-code) since Thu 2022-02-17 21:26:47 MSK; 25s ago
What: /dev/zram2
Docs: man:fstab(5)
man:systemd-fstab-generator(8)
[root@hp15 ~]# systemctl status dev-zram3.swap
● dev-zram3.swap - /dev/zram3
Loaded: loaded (/etc/fstab; generated)
Active: active (Result: exit-code) since Thu 2022-02-17 21:26:48 MSK; 26s ago
What: /dev/zram3
Docs: man:fstab(5)
man:systemd-fstab-generator(8)
[root@hp15 ~]#
У меня подозрение, что systemd по какой-то причине бежит впереди паровоза и пытается активировать zram до того, как он реально создается udev. Как это побороть?