Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Systemd and noauto in fstab headache

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
niowluka
Posts: 4
Joined: 2019-07-27 04:07

Systemd and noauto in fstab headache

#1 Post by niowluka »

Hi everybody, new to the forum, fairly new to Debian, long time Linux user.

I am completely new to systemd though, and really struggling to set up some mount points. Here are some of the problematic entries in fstab:

Code: Select all

/dev/mapper/cryptdata-2tb	/home/niowluka/Videos	btrfs	subvol=videos,defaults,noatime,noexec,user,comment=x-gvfs-hide 0 0
/dev/mapper/cryptdata-2tb	/mnt/archive/music	btrfs	subvol=music,defaults,noatime,noexec,user,noauto,comment=x-gvfs-show,comment=x-gvfs-name=Archive\040Music 0 0
/dev/mapper/cryptdata-8tb	/mnt/archive/videos	ext4	defaults,noatime,noexec,user,noauto,comment=x-gvfs-show,comment=x-gvfs-name=Archive\040Video 0 0

UUID=68233986-c957-427a-af4e-e5208bf08e20 /mnt/debian/root	btrfs	subvolid=5,defaults,noatime,ssd,compress=lzouser,noauto,comment=x-gvfs-show,comment=x-gvfs-name=Debian\040Root 0 0
Line 1 mounts with no problem at boot OK

Line 2 doesn't mount at boot (noauto), shows up nicely in nautilus and thunar side pane (x-gvfs), but mounting from there fails with '... already mounted on ...' error. I tried adding x-systemd.automount, but that's just causing it to mount at boot, and also creating my own .automount unit (with After=local-fs.target to not mount at boot), but it fails to mount with the same error.
I can mount it with 'mount /mnt/archive/music' from CLI before I try to do it from the file manager, but if I do it after I get the same error in CLI (presumably because of generated .mount and .automount units). FAIL

Line 3 doesn't mount at boot (noauto), shows up nicely in nautilus and thunar side pane, and I can mount it from there, but it asks for password, even though user is specified. Another problem is that after unmounting it seems to close/remove the devmapper device ... Again, all works fine from CLI before I do anything in the file manager FAIL

Line 4 doesn't mount at boot (noauto), shows up nicely in nautilus and thunar side pane (x-gvfs), but mounting it fails with 'only permitted for root', i.e. why doesn't it ask for password ? FAIL

How can I set up those mount points to not mount at boot, but be easily mountable (right click - mount) from nautilus or thunar ?

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: Systemd and noauto in fstab headache

#2 Post by L_V »

The internal drives owner is root.
Then a user cannot mount internal drives without special privilege: this is logic.

The trick is in polkit-1 (policykit-1 package).
If you want to weaken the permission, you can by creating your own policy rule to be placed at

Code: Select all

/etc/polkit-1/localauthority/50-local.d/10-MyMountRules.pkla
I don't give you the exact content, because it would need some fresh test for Buster, and I don't need it.
But you can investigate this to start.

Code: Select all

/usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy

  <action id="org.freedesktop.udisks2.filesystem-mount-system">
    <description>Mount a filesystem on a system device</description>
    <defaults>
      <allow_any>auth_admin</allow_any>
      <allow_inactive>auth_admin</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>
Directly editing /usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy is not recommended...., but ... replacing auth_admin by yes should have some effect.

+ have a look at

Code: Select all

systemctl list-unit-files | grep mount
However, if you decide to mount your shared partitions at boot, for info, I use this option in fstab

Code: Select all

noauto,x-systemd.automount

niowluka
Posts: 4
Joined: 2019-07-27 04:07

Re: Systemd and noauto in fstab headache

#3 Post by niowluka »

Thanks @L_V. I assume the polkit changes your propose would allow a user to mount any drive without privileges ? That's not exactly what I'm after, would rather there was a way to mount it from file manager, but with a password prompt ... Worst case I'd rather add user to fstab for this one.

It's the first 3 entries that I'm mostly interested in, though ...
L_V wrote:However, if you decide to mount your shared partitions at boot, for info, I use this option in fstab

Code: Select all

noauto,x-systemd.automount
What's the advantage of adding both of these over not adding either of those ?

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: Systemd and noauto in fstab headache

#4 Post by L_V »

niowluka wrote:That's not exactly what I'm after, would rather there was a way to mount it from file manager, but with a password prompt ...
It is sometimes better to take more time to exactly define what you want before looking for a solution.
What you ask is exactly what a lot of applications requesting a root access are doing, and managing via policy-kit / gparted for example.

Code: Select all

/usr/share/polkit-1/actions/org.gnome.gparted.policy

<policyconfig>
    <vendor>The GParted Project</vendor>
    <vendor_url>https://gparted.org</vendor_url>
    <icon_name>gparted</icon_name>
    <action id="org.gnome.gparted">
        <description>Run GParted as root</description>
        <message>Authentication is required to run the GParted Partition Editor as root</message>
        <defaults>
            <allow_any>auth_admin</allow_any>
            <allow_inactive>auth_admin</allow_inactive>
            <allow_active>auth_admin</allow_active>
        </defaults>
        <annotate key="org.freedesktop.policykit.exec.path">/usr/sbin/gparted</annotate>
        <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
    </action>
</policyconfig>
I just gave you inputs to get inspired...

Concerning "noauto,x-systemd.automount" fstab option, don't ask me to explain how fstab is interpreting auto or x-system inputs....
Found with some look around, tested, approved and fitting my need. That's it !

I even have an idea for you.....
Try to comment your shared partitions in your fstab, and see what happen.....
By default, what happen in my system is exactly what you are looking for (with Dolphin in KDE).

niowluka
Posts: 4
Joined: 2019-07-27 04:07

Re: Systemd and noauto in fstab headache

#5 Post by niowluka »

L_V wrote:It is sometimes better to take more time to exactly define what you want before looking for a solution.
I thought I was being pretty clear on what I want - I'd like to be able to mount the mountpoints from fstab from a file manager, without systemd mounting them automatically at boot. Apologies if that didn't come out in the post.
L_V wrote:Concerning "noauto,x-systemd.automount" fstab option, don't ask me to explain how fstab is interpreting auto or x-system inputs....
I didn't and I wasn't going to. I asked why you think this is better, as I don't see any advantage. In both cases the drives will be mounted automatically at boot by systemd.
L_V wrote:I even have an idea for you.....
Try to comment your shared partitions in your fstab, and see what happen.....
By default, what happen in my system is exactly what you are looking for (with Dolphin in KDE).
It'll be the same as before I started editing the fstab in the first place, won't it ?

Will look into the polkit, but seems like an overkill, especially considering how easy it was before systemd ... Like I said, I could live with user in fstab for this one.

Any ideas about the other issues ?

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: Systemd and noauto in fstab headache

#6 Post by L_V »

niowluka wrote:I didn't and I wasn't going to. I asked why you think this is better, as I don't see any advantage. In both cases the drives will be mounted automatically at boot by systemd.
You ask, but don't experiment enough.
What was working with "auto" for Strecth was not working for Buster anymore, and this is why I have introduced x-systemd.automount in fstab.
It is not because it is "better", but because it works.
This is for a partition I want to mount at boot.

Now, for a partition which is not in the fstab, I just tell you that without doing anything, this partition is visible in Dolphin, and if I click on it, a pop-up window will request a password.
I understood this is what your were looking for.
Now, if you don't have the same behaviour, may be "thunar" I never used does not work the same as Dolphin. I never used gnome.

May be policykit-1-gnome can help you to investigate.

niowluka
Posts: 4
Joined: 2019-07-27 04:07

Re: Systemd and noauto in fstab headache

#7 Post by niowluka »

L_V wrote:You ask, but don't experiment enough.
I'm new here, I'll ignore that.

L_V
Posts: 1477
Joined: 2007-03-19 09:04
Been thanked: 11 times

Re: Systemd and noauto in fstab headache

#8 Post by L_V »

policykit-1-gnome / investigation for gnome users

Code: Select all

/usr/share/doc/policykit-1-gnome/README
/etc/xdg/autostart/polkit-gnome-authentication-agent-1.desktop
/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1

Post Reply