maximumadmin / zramd

Automatically setup swap on zram ✨ with optional systemd support, a simpler alternative to zram-generator and systemd-swap
MIT License
94 stars 2 forks source link

systemd v254 changes swapon output for zram device #23

Open glitsj16 opened 1 year ago

glitsj16 commented 1 year ago

Hi, let me start by expressing my gratitude for creating/offering this excellent application. Have been using it without hiccups for a long time. But after my Arch Linux box got the systemd v254 recently, I did notice some peculiarity. Where before this upgrade swapon consistently reported /dev/zram0, it now shows /zram0 instead.

$ sudo swapon --noheadings --raw --show=name,size,used
/dev/sda2 4,2G 0B
/zram0 1024M 0B

UPDATE: After doing some more experimenting it turned out we can keep PrivateNetwork and explicitly disable PrivateMounts.

Nothing crucial apparently, the zram device is created and still resides under /dev/zram0. But it's confusing and I opted to disable PrivateNetwork PrivateMounts to get back to the output one would expect from swapon.

https://github.com/maximumadmin/zramd/blob/a21eb478ee91974d57abf164508f1c991ae80044/build/package/zramd.service#L11

$ cat /etc/systemd/system/zramd.service.d/fix-swapon-output.conf
[Service]
# systemd v254 introduced some changes that apparently affected
# swapon output - bring back known good behaviour
# https://github.com/systemd/systemd/commit/6b2d576f2b38c0385bb056af328754ec8966f9fd
PrivateMounts=no

Not sure whether there might be better ways to deal with this systemd change. I'll leave that up to you.