I want accomplish the following task: On a Ubuntu System with multiple Users accounts and encrypted Home directorys a NFS share should be mounted after login. I want to use systemd user service for this, but can't get it fully working.

What's working so far: - manual mount with user rights, configured with sudo - enabling the user service and starting it with systemctl --user start usermount.service

After a reboot systemd doesn't even know that this unit exists. I think there is a problem in combination with an encrypted $HOME (ecryptfs in my case), because the service unit and autostart configuration are located in .config/systemd/user/. My assumption is that the systemd user process is started immediatly after login, before decrypting the homedir and hence doesn't see the users configuration.

Whats my possibilities to solve this task?

  • 1
    I have a similar issue on Arch and came to the same conclusion: “the systemd user process is started immediately after login, before decrypting the homedir and hence doesn't see the users configuration”. I'd also add that it's stopped after unmounting the homedir, so any service which needs to access the homedir at shutdown won't work either. This is even more true when using systemd lingering, which makes user services start after boot, even if the user doesn't log in at all. – Arkanosis Jul 23 '18 at 9:24

It's a bug in the ecryptfs package configuration. You can use a quick fix: Open /etc/pam.d/common-session and switch the lines

session optional        pam_systemd.so
session optional        pam_ecryptfs.so unwrap


session optional        pam_ecryptfs.so unwrap
session optional        pam_systemd.so

so that pam_systemd.so is loaded after pam_ecryptfs.so

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.