[Pkg-utopia-maintainers] Bug#931399: zram-setup@ ConditionPathExists= (only run when zram is configured by udisks2)
Trent W. Buck
trentbuck at gmail.com
Thu Jul 4 03:21:39 BST 2019
Package: udisks2
Version: 2.8.1-4
Severity: minor
File: /lib/systemd/system/zram-setup at .service
Tags: patch
The core package (i.e. udisk2, not udisks2-zram) ships a udev rule and a systemd unit to configure zram.
These fire on "modprobe zram", even when udisks2-zram isn't installed, and udisks-specific config file doesn't exist.
Please add the following line to modules/zram/data/zram-setup at .service, so it will only fire when it should:
[Unit]
ConditionPathExists=/usr/local/lib/zram.conf.d/%i-env
You might also want to change this rule so it won't report an error when SWAP=n:
-ExecStart=-/bin/sh -c '[ "$SWAP" = "y" ] && mkswap /dev/%i && swapon /dev/%i'
+ExecStart=/bin/sh -c 'if [ "$SWAP" = "y" ]; then mkswap /dev/%i && swapon /dev/%i; fi'
You might also like the confinement suggestions of "systemd-analyze security zram-setup@".
-- System Information:
Debian Release: 10.0
APT prefers testing
APT policy: (990, 'testing'), (500, 'testing-proposed-updates'), (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 4.19.0-5-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8), LANGUAGE=en_AU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages udisks2 depends on:
ii dbus 1.12.16-1
ii libacl1 2.2.53-4
ii libatasmart4 0.19-5
ii libblockdev-fs2 2.20-7
ii libblockdev-loop2 2.20-7
ii libblockdev-part2 2.20-7
ii libblockdev-swap2 2.20-7
ii libblockdev-utils2 2.20-7
ii libblockdev2 2.20-7
ii libc6 2.28-10
ii libglib2.0-0 2.58.3-2
ii libgudev-1.0-0 232-2
ii libmount1 2.33.1-0.1
ii libpam-systemd 241-5
ii libpolkit-agent-1-0 0.105-25
ii libpolkit-gobject-1-0 0.105-25
ii libsystemd0 241-5
ii libudisks2-0 2.8.1-4
ii parted 3.2-25
ii udev 241-5
Versions of packages udisks2 recommends:
ii dosfstools 4.1-2
ii e2fsprogs 1.44.5-1
ii eject 2.1.5+deb1+cvs20081104-13.2
ii exfat-utils 1.3.0-1
ii libblockdev-crypto2 2.20-7
ii ntfs-3g 1:2017.3.23AR.3-3
ii policykit-1 0.105-25
Versions of packages udisks2 suggests:
ii btrfs-progs 4.20.1-2
pn f2fs-tools <none>
pn libblockdev-mdraid2 <none>
pn mdadm <none>
pn nilfs-tools <none>
pn reiserfsprogs <none>
pn udftools <none>
pn udisks2-bcache <none>
pn udisks2-btrfs <none>
pn udisks2-lvm2 <none>
pn udisks2-vdo <none>
pn udisks2-zram <none>
pn xfsprogs <none>
-- no debconf information
-------------- next part --------------
Demonstrating the initial problem:
bash5$ systemctl status | head -2
● goll
State: running
bash5$ dpkg-query -W udisks2 udisks2-zram
udisks2 2.8.1-4
udisks2-zram
bash5$ sudo modprobe zram
bash5$ systemctl status zram-setup at zram0
● zram-setup at zram0.service - Setup zram based device zram0
Loaded: loaded (/lib/systemd/system/zram-setup at .service; static; vendor preset: enabled)
Active: active (exited) since Thu 2019-07-04 11:20:11 AEST; 17s ago
Process: 1023 ExecStart=/bin/sh -c echo $ZRAM_NUM_STR > /sys/class/block/zram0/max_comp_streams (code=exited, status=0/SUCCESS)
Process: 1028 ExecStart=/bin/sh -c echo $ZRAM_DEV_SIZE > /sys/class/block/zram0/disksize (code=exited, status=1/FAILURE)
Process: 1031 ExecStart=/bin/sh -c [ "$SWAP" = "y" ] && mkswap /dev/zram0 && swapon /dev/zram0 (code=exited, status=1/FAILURE)
Main PID: 1031 (code=exited, status=1/FAILURE)
Jul 04 11:20:11 goll systemd[1]: Starting Setup zram based device zram0...
Jul 04 11:20:11 goll sh[1028]: /bin/sh: 1: echo: echo: I/O error
Jul 04 11:20:11 goll systemd[1]: Started Setup zram based device zram0.
Demonstrating the fix:
bash5$ sudo systemctl stop zram-setup at zram0
bash5$ sudo rmmod zram
bash5$ sudo SYSTEMD_EDITOR=ed systemctl edit zram-setup@
0
i
[Unit]
ConditionPathExists=/usr/local/lib/zram.conf.d/%i-env
.
w
61
q
bash5$ sudo modprobe zram
bash5$ systemctl status zram-setup at zram0 -l
● zram-setup at zram0.service - Setup zram based device zram0
Loaded: loaded (/lib/systemd/system/zram-setup at .service; static; vendor preset: enabled)
Drop-In: /etc/systemd/system/zram-setup at .service.d
└─override.conf
Active: inactive (dead)
Condition: start condition failed at Thu 2019-07-04 11:47:30 AEST; 40s ago
└─ ConditionPathExists=/usr/local/lib/zram.conf.d/zram0-env was not met
[...]
Jul 04 11:47:30 goll systemd[1]: Condition check resulted in Setup zram based device zram0 being skipped.
Demonstrating the fix doesn't break things for existing users:
bash5$ sudo systemctl stop zram-setup at zram0
bash5$ sudo rmmod zram
bash5$ sudo mkdir /usr/local/lib/zram.conf.d
bash5$ VISUAL= EDITOR=ed sudoedit /usr/local/lib/zram.conf.d/zram0-env
0
i
# This is based on udiskslinuxmanagerzram.c:create_conf_files
ZRAM_NUM_STR=4
ZRAM_DEV_SIZE=409600
SWAP=n
.
w
105
q
bash5$ sudo modprobe zram
bash5$ systemctl status zram-setup at zram0
● zram-setup at zram0.service - Setup zram based device zram0
Loaded: loaded (/lib/systemd/system/zram-setup at .service; static; vendor preset: enabled)
Drop-In: /etc/systemd/system/zram-setup at .service.d
└─override.conf
Active: active (exited) since Thu 2019-07-04 12:01:35 AEST; 6s ago
Process: 3623 ExecStart=/bin/sh -c echo $ZRAM_NUM_STR > /sys/class/block/zram0/max_comp_streams (code=exited, status=0/SUCCESS)
Process: 3624 ExecStart=/bin/sh -c echo $ZRAM_DEV_SIZE > /sys/class/block/zram0/disksize (code=exited, status=0/SUCCESS)
Process: 3625 ExecStart=/bin/sh -c [ "$SWAP" = "y" ] && mkswap /dev/zram0 && swapon /dev/zram0 (code=exited, status=1/FAILURE)
Main PID: 3625 (code=exited, status=1/FAILURE)
Jul 04 12:01:35 goll systemd[1]: Starting Setup zram based device zram0...
Jul 04 12:01:35 goll systemd[1]: Started Setup zram based device zram0.
bash5$
More information about the Pkg-utopia-maintainers
mailing list