You are not logged in.

#1 2019-02-17 08:17:34

Kotrfa
Member
Registered: 2012-10-25
Posts: 213

[SOLVED] systemctl user services not discovered with encrypted disk

Hey,

I have my home directory encrypted (LUKS) and use a pretty standard configuration of decryption after login. I want to leverage `systemd --user` spawned services, but the problem is that because the disk is decrypted after the login, the user services are not discovered.

I have for example this:

# cat .config/systemd/user/rescuetime.service

[Unit]
Description=rescutime monitoring app
After=display-manager.service
#Requires=home-dan.mount

[Service]
ExecStartPre=/bin/sleep 10
ExecStart=/usr/bin/rescuetime
Restart=always
RestartSec=5

[Install]
WantedBy=default.target

but it still doesn't work if I reboot. When I do `enable/start/status` after login (and therefore mount), it works as expected.

I tried different combination to play with Required and After etc., read these posts:

* https://bbs.archlinux.org/viewtopic.php?id=201781
* https://unix.stackexchange.com/question … h-ecryptfs
* https://askubuntu.com/questions/1090634 … ter-reboot

but still nothing. I found that it is supposed to be known limitation, but the proposed solution doesn't work because I cannot get the `systemctl --user daemon-reload` work for the user when ran as system-wide service.

# /etc/systemd/system/systemd-reload-after-mount.service
[Unit]
Description=reloads units stored in mounted filesystems
DefaultDependencies=no
After=home-dan.mount
Requires=home-dan.mount


[Service]
Type=oneshot
Environment="DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus"
Environment="USER=dan"
Environment="XDG_RUNTIME_DIR=/run/user/1000"
ExecStart=/bin/systemctl --user daemon-reload
#ExecStartPost=/bin/systemctl --user start rescuetime.service

[Install]
WantedBy=local-fs.target

^ from that, after a restart, I get:

● systemd-reload-after-mount.service - reloads units stored in mounted filesystems
   Loaded: loaded (/etc/systemd/system/systemd-reload-after-mount.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sun 2019-02-17 21:41:46 CET; 7min ago
  Process: 1318 ExecStart=/bin/systemctl --user daemon-reload (code=exited, status=1/FAILURE)
 Main PID: 1318 (code=exited, status=1/FAILURE)

Feb 17 21:41:46 think460s systemctl[1318]: Failed to connect to bus: Operation not permitted
Feb 17 21:41:46 think460s systemd[1]: Starting reloads units stored in mounted filesystems...
Feb 17 21:41:46 think460s systemd[1]: systemd-reload-after-mount.service: Main process exited, code=exited, status=1/FAILURE
Feb 17 21:41:46 think460s systemd[1]: systemd-reload-after-mount.service: Failed with result 'exit-code'.
Feb 17 21:41:46 think460s systemd[1]: Failed to start reloads units stored in mounted filesystems.

and that's where I ended. I haven't found how to make it work (i.e. not to get operation not permitted) nor any other hints for the --user services on mounted home.

Thanks

Last edited by Kotrfa (2019-02-20 21:02:43)

Offline

#2 2019-02-20 21:04:11

Kotrfa
Member
Registered: 2012-10-25
Posts: 213

Re: [SOLVED] systemctl user services not discovered with encrypted disk

It just doesn't work. I had to add `daemon-reload` and then start the services when spinning up my WM. In my case of i3 window manager, I had to add this:

exec --no-startup-id "systemctl --user daemon-reload; systemctl --user start rescuetime; systemctl --user start redshift-gtk"

Offline

Board footer

Powered by FluxBB