• Stop udisks2 mounting my partitions?

    From Stefan Monnier@21:1/5 to All on Wed Jul 23 02:20:01 2025
    On one of my (Debian stable) machines, all the partitions that aren't
    mentioned in /etc/fstab end up mounted in /media/root/<UUID>, and that's apparently a "feature" of `udisks2`.

    How can I tell udisks2 to refrain from doing that?

    [ Note: I tried removing udisks2 altogether, but it's required
    by other packages that I don't want to remove. ]

    Note also that I'm not completely sure that udisks2 is directly the one
    that decides to mount those disks. Maybe it's only the "executioner",
    obeying orders from some other package, but if so, I don't know what
    that other package would be.


    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andy Smith@21:1/5 to Stefan Monnier on Wed Jul 23 02:50:01 2025
    Hi,

    On Tue, Jul 22, 2025 at 08:11:44PM -0400, Stefan Monnier wrote:
    On one of my (Debian stable) machines, all the partitions that aren't mentioned in /etc/fstab end up mounted in /media/root/<UUID>, and that's apparently a "feature" of `udisks2`.

    How can I tell udisks2 to refrain from doing that?

    I'm not sure if it's the best/easiest way, but in the past I've used
    udev rules with ENV{UDISKS_IGNORE}="1":

    https://wiki.archlinux.org/title/Udisks#Hide_selected_partitions

    You could instead put the thing in fstab with a "noauto" as one of its
    mount options. Then it wouldn't be mounted by the system at boot, nor by udisks.

    Obviously you can stop all automounting by stopping the udisks2 service
    (and maybe masking it). That leaves it installed but not running. Some
    software wants it to be running though.

    Although it is udisks2 and udev that are facilitating this, I thought it
    only happened inside a desktop environment. Though your example of /media/root/UUID suggests not. Anyway, some ideas for desktop
    environments:

    https://www.baeldung.com/linux/ubuntu-disable-automated-mounting

    Thanks,
    Andy

    --
    https://bitfolk.com/ -- No-nonsense VPS hosting

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Monnier@21:1/5 to All on Wed Jul 23 05:10:01 2025
    On one of my (Debian stable) machines, all the partitions that aren't
    mentioned in /etc/fstab end up mounted in /media/root/<UUID>, and that's >>> apparently a "feature" of `udisks2`.

    How can I tell udisks2 to refrain from doing that?

    If you do not like automounting on connecting a drive then change settings
    of your desktop environment.

    FWIW, this is a headless SBC I use as home server. I do connect it to
    an HDMI screen occasionally when I need to debug boot issues, but
    I don't have any Xorg or Wayland installed on it.

    I do occasionally log into it as root over the serial connection.
    Maybe that's what triggers the auto-mount?

    If you do not like that mounted partitions can not be accessed by
    users other than root then add udev hints for specific partitions, see udisks(8) and

    No, it's rather than I don't like those filesystems being mounted at all
    (it gets in the way of messing with the filesystem behind the kernel's
    back, for example).

    I'm not sure if it's the best/easiest way, but in the past I've used
    udev rules with ENV{UDISKS_IGNORE}="1":
    https://wiki.archlinux.org/title/Udisks#Hide_selected_partitions
    It is used by desktop environment automounters and file managers rather than udisks itself.

    The only file manager I use as root is `zsh`. 🙂

    You could instead put the thing in fstab with a "noauto" as one of its
    mount options. Then it wouldn't be mounted by the system at boot, nor by
    udisks.

    That's an idea. I'd have preferred a way to avoid having to list each
    and every such partition, but it's better than nothing, thanks.

    It is a viable approach as well since arbitrary mount point may be specified instead of /media/LABEL and /media/UUID hardcoded in udisks2. Users are
    still able to do "udisksctl mount -b ...".

    Oh, right. Hmm....


    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Monnier@21:1/5 to All on Wed Jul 23 05:20:01 2025
    Max Nikulin [2025-07-23 08:58:56] wrote:
    On 23/07/2025 07:11, Stefan Monnier wrote:
    On one of my (Debian stable) machines, all the partitions that aren't
    mentioned in /etc/fstab end up mounted in /media/root/<UUID>, and that's
    apparently a "feature" of `udisks2`.
    Is it another attempt to solve the earlier raised issue?

    Aha! I did have the impression of a "d�j� vu", but I usually keep notes
    about such things and there wasn't anything in my notes. Weird.

    In any case, yes `udisksctl dump` shows clearly that it's under its control.

    But I can't find anything in the docs about controlling whether
    something gets mounted or not, all I find are options to control *how*
    it's mounted (and to give the right to some users, but `root` always
    has the rights, anyway).

    Are there any traces of mounting in "journalctl -b" output (as root)?
    I would check if ext4 metadata contains timestamp when it was mounted. It
    may be a hint helping to find what happened around that moment.

    Good idea, I'll take a look, thanks.


    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Greg Wooledge@21:1/5 to Stefan Monnier on Wed Jul 23 13:10:01 2025
    On Tue, Jul 22, 2025 at 23:16:19 -0400, Stefan Monnier wrote:
    all I find are options to control *how*
    it's mounted (and to give the right to some users, but `root` always
    has the rights, anyway).

    That last bit is not always true. There are several types of mounts
    where some non-UID-0 user has more privileges than UID 0 does. NFS is
    one example (unless the mount is done with no_root_squash). Another is
    this:

    hobbit:~$ ls -ld /run/user/1000/doc
    dr-x------ 2 greg greg 0 Dec 31 1969 /run/user/1000/doc/
    hobbit:~$ sudo ls -ld /run/user/1000/doc
    ls: cannot access '/run/user/1000/doc': Permission denied
    hobbit:~$ mount | grep doc
    portal on /run/user/1000/doc type fuse.portal (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Monnier@21:1/5 to All on Wed Jul 23 15:40:01 2025
    all I find are options to control *how*
    it's mounted (and to give the right to some users, but `root` always
    has the rights, anyway).
    That last bit is not always true.

    What I meant is that root does have the access rights needed to mount
    those devices and the access-control I find in Udisks don't help in
    that case.


    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Monnier@21:1/5 to All on Wed Jul 23 16:00:01 2025
    May it happen that it is not really automounting, but some package script running on "apt upgrade" or some cron task or systemd timer specific to
    the board?

    I don't know what's the difference between what you describe and "automounting". What I mean by "automounting" is not the `autofs` kind
    of mounting on demand, but really just having the drives mounted without
    any explicit action on my part that requests it.


    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Monnier@21:1/5 to All on Wed Jul 23 18:20:01 2025
    Is this done by the desktop environment?
    Does it still happen if booting without the graphical environment?

    [ If you go back up the thread, you'll see this has been asked and
    answered already. ]

    This is a headless home server. No graphical desktop environment
    in sight.


    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Monnier@21:1/5 to All on Thu Jul 24 16:00:01 2025
    Aha! I did have the impression of a "d�j� vu", but I usually keep notes
    about such things and there wasn't anything in my notes. Weird.
    You suspected vgchange. Have you managed to trigger mount in response to
    some command? If system logs are not verbose enough then monitoring D-Bus might help.

    I found the culprit: system logs revealed it's done by `plinth` (part
    of FreedomBox).

    In any case, yes `udisksctl dump` shows clearly that it's under its control.

    Do you mean "UserspaceMountOptions: uhelper=udisks2"? The tool reports (almost) all available drives and partitions even if they are mounted "directly" without udisks.

    Yup:

    # udisksctl dump | grep -A2 uhelper=udisks2
    UserspaceMountOptions: uhelper=udisks2
    org.freedesktop.UDisks2.Filesystem:
    MountPoints: /media/root/c540ec8e-27d6-4ea8-9a87-fab1205ab207
    --
    UserspaceMountOptions: uhelper=udisks2
    org.freedesktop.UDisks2.Filesystem:
    MountPoints: /media/root/64228374-ad64-4f9e-8c7a-a7687e7ed057
    #


    - Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Monnier@21:1/5 to All on Fri Jul 25 21:00:01 2025
    On one of my (Debian stable) machines, all the partitions that aren't
    mentioned in /etc/fstab end up mounted in /media/root/<UUID>, and that's
    apparently a "feature" of `udisks2`.

    How can I tell udisks2 to refrain from doing that?

    I'm not sure if it's the best/easiest way, but in the past I've used
    udev rules with ENV{UDISKS_IGNORE}="1":

    https://wiki.archlinux.org/title/Udisks#Hide_selected_partitions

    So far it seems to be the best option, thank you. Sadly the doc I found doesn't say what is the meaning/effect of `UDISKS_IGNORE/SYSTEM/AUTO`
    nor what values those vars can take (e.g. I had tried "yes" instead of
    "1" and that seem to have no effect).

    You could instead put the thing in fstab with a "noauto" as one of its
    mount options. Then it wouldn't be mounted by the system at boot, nor by udisks.

    I have a growing number of such partitions, so it's not very practical.

    Although it is udisks2 and udev that are facilitating this, I thought it
    only happened inside a desktop environment. Though your example of /media/root/UUID suggests not. Anyway, some ideas for desktop
    environments:

    In my case it's FreedomBox which does it, so you can just plug in a USB
    key or SD card into your machine and have it accessible without any
    extra work. I can see the desire for it, but in my case it's
    significantly harder to plug something into the "box" than it is to ssh
    to it and type `mount`. 🙁
    Also, in my case about half the time I connect a USB key or an SD card
    it's not to access its contents but to write a whole new image onto it (partition table and all), so auto-mounting is really not helpful.

    For the record, the solution I used is simply to create a one-line file:

    # cat /etc/udev/rules.d/99-my-stop-udisk.rules
    ENV{UDISKS_IGNORE}="1"
    #

    Thank you everyone for your help along the way.


    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Wright@21:1/5 to Stefan Monnier on Fri Jul 25 22:10:01 2025
    On Fri 25 Jul 2025 at 14:51:03 (-0400), Stefan Monnier wrote:
    On one of my (Debian stable) machines, all the partitions that aren't
    mentioned in /etc/fstab end up mounted in /media/root/<UUID>, and that's >> apparently a "feature" of `udisks2`.

    How can I tell udisks2 to refrain from doing that?

    I'm not sure if it's the best/easiest way, but in the past I've used
    udev rules with ENV{UDISKS_IGNORE}="1":

    https://wiki.archlinux.org/title/Udisks#Hide_selected_partitions

    So far it seems to be the best option, thank you. Sadly the doc I found doesn't say what is the meaning/effect of `UDISKS_IGNORE/SYSTEM/AUTO`
    nor what values those vars can take (e.g. I had tried "yes" instead of
    "1" and that seem to have no effect).

    true/false I would imagine. See:

    https://storaged.org/doc/udisks2-api/latest/udisks.8.html

    and:

    https://storaged.org/doc/udisks2-api/latest/gdbus-org.freedesktop.UDisks2.Block.html

    No idea why they split the information across two pages.

    Cheers,
    David.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Monnier@21:1/5 to All on Sat Jul 26 00:00:01 2025
    true/false I would imagine. See:

    https://storaged.org/doc/udisks2-api/latest/udisks.8.html

    and:

    https://storaged.org/doc/udisks2-api/latest/gdbus-org.freedesktop.UDisks2.Block.html

    Ah, that's where those HintFoo thingies are documented.
    DDG wasn't able to get me to
    `gdbus-org.freedesktop.UDisks2.Block.html` when I searched for info
    about the HintSystemand HintIgnore property.

    I don't think the end-users reading the manpage should have to refer to
    the DBus interface docs to know what to do and what does what.


    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)