Are you sure it's homescott and not homeScott as well on the dev mapper? Did you run the paths you are referring to through
systemd-escape -p
as recommended to get the correct escape sequences?
I did.
Ok, so I did some more playing. It seems to work, despite the error. I think device units appear to be treated uniquely by systemd as they do not have unit files. I'm confused, this seems to be resolved in that it seems to work, but I believe the warning is erroneous.
]]>systemd-escape -p
as recommended to get the correct escape sequences?
]]>[Unit]
DefaultDependencies=no
BindsTo=dev-disk-by\x2dpartlabel-homeScott.device
After=dev-disk-by\x2dpartlabel-homeScott.device
BindsTo=dev-mapper-homescott.device
Requires=home-scott.mount
Before=home-scott.mount
Conflicts=umount.target
Before=umount.target
[Service]
Type=oneshot
RemainAfterExit=yes
TimeoutSec=0
ExecStop=/usr/bin/cryptsetup close homescott
[Install]
RequiredBy=dev-mapper-homescott.device
Which, when enabled, yields the following error:
Unit /etc/systemd/system/cryptsetup-scott.service is added as a dependency to a non-existent unit dev-mapper-homescott.device.
But once installed, I can check the status:
● cryptsetup-scott.service
Loaded: loaded (/etc/systemd/system/cryptsetup-scott.service; enabled; preset: disabled)
Active: active (exited) since Wed 2022-11-23 16:59:16 CST; 21min ago
Nov 23 16:59:16 frameWork systemd[1]: Finished cryptsetup-scott.service.
and
dev-mapper-homescott.device - /dev/mapper/homescott
Follows: unit currently follows state of sys-devices-virtual-block-dm\x2d0.device
Loaded: loaded
Active: active (plugged) since Wed 2022-11-23 16:59:16 CST; 22min ago
Until: Wed 2022-11-23 16:59:16 CST; 22min ago
Device: /sys/devices/virtual/block/dm-0
Nov 23 16:59:16 frameWork systemd[1]: Condition check resulted in /dev/mapper/homescott being skipped.
Why is it interested in dev-mapper-homeusername.device when you specified dev-mapper-home\x2dusername.device? Isn't that the difference between /dev/mapper/homeusername and /dev/mapper/home-username? Is it correct that
Requires=home-username.mount Before=home-username.mount
aren't escaped?
I apologize for the confusion, I used homeusername instead of home-username. All of the files are consistently hyphenated, but I copied the codeblock from the wiki, even though the actual used names are obviously specific to my system. In short, they both are homeusername. Sorry.
I believe because those are unit names, they aren't escaped, but device units are escaped. Honestly, I'm not really clear on when/why the escaping happens. But, this is how they are written in the wiki. I've had success with it in the past.
I think the escapes are correct.
The hyphenation issue is also consistent on the actual system (I didn't yet have internet on that system when I was writing this so I mostly copy/pasted).
The bigger question I have is why systemd claims a device unit that definitely exists is claimed not to exist.
]]>Requires=home-username.mount
Before=home-username.mount
aren't escaped?
]]>I'm thinking this is a udev issue or something? Why would a device unit have an active status and yet yield an error when making dependents upon it?
]]>Thanks!
]]>RequiredBy=sys-devices-virtual-block-dm\x2d0.device
This also resulted in the same error.
]]>I've contributed to/used the auto-mount at login setup on the wiki a half dozen or more times, under a variety of distros (including two Arch laptops). I've never seen this issue before.
On the framework laptop, I'm having an issue with the final systemd unit script:
[Unit]
DefaultDependencies=no
BindsTo=dev-PARTITION.device
After=dev-PARTITION.device
BindsTo=dev-mapper-home\x2dusername.device
Requires=home-username.mount
Before=home-username.mount
Conflicts=umount.target
Before=umount.target
[Service]
Type=oneshot
RemainAfterExit=yes
TimeoutSec=0
ExecStop=/usr/bin/cryptsetup close home-username
[Install]
RequiredBy=dev-mapper-home\x2dusername.device
This unit should lock/close the device on logout.
I've written the script, but when I go to install/enable it, I get the following error:
Unit /etc/systemd/system/cryptsetup-homeusername.service is added as a dependency to a non-existent unit dev-mapper-homeusername.device.
I understand the script hyphenates the mapper differently, I've just copy/pasted from the script in the wiki. Everything is consistently hyphenated/named
however, despite this error, /dev/mapper/homeusername exists.
When I use systemctl status dev-mapper-homeusername, I get the following:
● dev-mapper-homeusername.device - /dev/mapper/homeusername
Follows: unit currently follows state of sys-devices-virtual-block-dm\x2d0.device
Loaded: loaded
Active: active (plugged) since Sun 2022-11-20 21:25:36 CST; 22min ago
Until: Sun 2022-11-20 21:25:36 CST; 22min ago
Device: /sys/devices/virtual/block/dm-0
Nov 20 21:25:36 frameWork systemd[1]: Condition check resulted in /dev/mapper/homeusername being skipped.
So, why is it showing up as an active device unit, but the unit appears non-existent on installation of a dependent unit?
Any ideas/guidance?