I would like a file based filesystem (~/Archives/inventory.locker) mounted upon user login and unmounted upon logout (~/Documents/Inventory).
pam_mount
seems to provide the functionality I am after, but it has incompatibilites with pam_systemd
.
I have tried writing a user based systemd.mount
unit, but it fails with:
mount: only root can do that
Even though I have the 'user' mount option defined and can successfully mount as user manually.
The systemd
method seems ideal because it requires no other dependencies and is also per user process and not per login session.
I am open to alternative solutions too.
Best Answer
Latecomer here. It may be a little counterintuitive, but I use the service (rather than mount) systemd user unit and it works for me. I had to add the
user
andnoauto
options to/etc/fstab
entry.You should enable the unit instance with a command such as:
Help with the
@
in the filename, can be found reading about systemd instantiated units.