You are not logged in.

#1 2022-09-19 10:30:23

NeverTooLate
Member
From: France
Registered: 2020-06-04
Posts: 6

Automount systemd user

Hi everybody !

I want to automount an external drive as a user on $HOME/mnt directory.

I did modify my /etc/fstab and add :

UUID=...    /home/myuser/mnt    ext4    user,noauto    0 0

To be able to mount the fs as a user (this works great).
But create mount and automount systemd user units, this doesn't seem to work (permission using mount syscall).

Am I forced to create a path unit (/dev/disk/by-uuid/...) and a service user unit that mount the fs for this automount ?
What is the right way to do this ?

Thanks !

Last edited by NeverTooLate (2022-09-19 10:41:10)

Offline

#2 2022-09-19 12:45:49

seth
Member
Registered: 2012-09-03
Posts: 49,954

Re: Automount systemd user

mount and automount systemd user units

Joe Shmoe doesn't get to mount random stuff - is the fstab entry still there?
What do the units look like?

That aside, what's wrong w/ either automounting the drive or adding "x-systemd.automount" as mount option (behind noauto) to mount it on demand?

Online

#3 2022-09-19 13:19:41

NeverTooLate
Member
From: France
Registered: 2020-06-04
Posts: 6

Re: Automount systemd user

Yes the fstab entry is there.

The units looks like this for mount :

[Unit]
Description= external drive to /home/myuser/mnt

[Mount]
What=/dev/disk/by-uuid/...
Where=/home/myuser/mnt
Type=ext4

[Install]
WantedBy=default.target

And for automount :

[Unit]
Description= external drive to /home/myuser/mnt

[Automount]
Where=/home/myuser/mnt

[Install]
WantedBy=default.target

The thing is I use systemd-homed, I just wanted the automount for this particular user and replicate the behavior on multiple computers. Anyway this seems impossible for security reasons...

Last edited by NeverTooLate (2022-09-19 13:21:17)

Offline

#4 2022-09-19 13:30:00

seth
Member
Registered: 2012-09-03
Posts: 49,954

Re: Automount systemd user

You could have a regular user service that simply executes "mount /home/myuser/mnt"?

Online

#5 2022-09-19 13:35:56

NeverTooLate
Member
From: France
Registered: 2020-06-04
Posts: 6

Re: Automount systemd user

With a path unit for checking udev like I said...
Yes but I still need that entry in the fstab anyway...like you said Joe Shmoe doesn't get to mount random stuff.

Offline

#6 2022-09-19 13:50:13

seth
Member
Registered: 2012-09-03
Posts: 49,954

Online

Board footer

Powered by FluxBB