Prevent automount of partitions by uuid

Hello,

Is there a way to prevent partitions (identified by uuid) from automounting (when an external disk is plugged in) ?
It can be done with udev rules on Raspbian. OSMC uses different tools to handle automount (a package called udisks-glue is installed).

On Raspbian in udev rules I just set ENV{UDISKS_IGNORE}:="1"
On OSMC I tried similar rules, with UDISKS_PRESENTATION_NOPOLICY instead of UDISKS_IGNORE, to no avail.

Do you want the drive to be prevented from mounting at all ? (If so why)

Or do you want to mount it by name or mount it at another location ?

The drive has 4 partitions, all of which automount. When I plug this drive to the Pi, I am not interested in using partition1 and partition2. I do need to automount them at all.

There is no straightforward way to stop a particular partition on a particular drive from automounting via udisks-glue.

You can override the mount points by creating a manual fstab entry - any partition that is already mounted before udisks-glue runs will be left alone. However creating an fstab entry that is set to not automount won’t work as udisks-glue will mount any unmounted local disks listed in fstab when it runs.

Okay then, I’ll live with the current behavior.

Indeed. The rules in /etc/udisks-glue.conf are designed to include, not exclude, something. I have not figured out a way to exclude a partition from the application of general rules. If I define a filter to include a partition by its uuid and then set automount to false in the corresponding match block, it appears that the automount setting gets overridden by the general rules in other match blocks (automount = true).

I ended up putting a hack (sigh) in the post_mount_command to unmount those partitions that I do not ever need to show up in the Files menu:
/media/RECOVERY
/media/SETTINGS
/media/boot
/media/root0

These partitions are the NOOBS partitions on my Raspberry Pi 3. I do not want to get rid of them at this point. They serve particular purposes. The last two partitions are the Raspbian’s partitions.

I tried experimenting with the udev rules too and found that they do not work as one would expect them to work. Perhaps this is OSMC’s feature.

I would much appreciate an option to hide certain partitions or prevent them from automounting in the future OSMC versions. Unnecessary items in the top-level Files menu are clutter.

Lastly, I tried overriding mount points with manual fstab entries too. It did not work. I mounted the partitions at different mounts points under /mnt but they still showed up in the Files menu.

1 Like

@DBMandrake

We should resurrect plans for udevil and refresh why we didn’t go move before. We can also look at udisks2 which has this capability.

I am in the same situation… Could you please post your udisks-glue.conf file, or the let me know exact changes you made?

thks!

@v1ncen7:

It looks like I am not allowed to upload a .conf file here. Below is the section of my udisks-glue.conf file that contains the code to unmount those unwanted partitions. Please compare this section with your unmodified /etc/udisks-glue.conf to see where the hack begins and where it ends.

match other-partitions {
    automount = true
    post_mount_command = '
            sudo chmod a+rwx "%mount_point" 2>/dev/null
            if [ -f /usr/bin/net ] && /bin/systemctl is-enabled samba > /dev/null 2>&1; then
                    count=120
                    while [ $count -gt 0 ]; do
                            if sudo /usr/bin/net usershare add "$(basename "%mount_point")" "%mount_point" "Auto-mount Volume" "$(hostname)\osmc:f"
                                    then break
                            fi
                    sleep 5; let count-=5
                    done
            fi
            for mpoint in /media/RECOVERY /media/SETTINGS /media/boot /media/root0
            do
                    mount | grep -q $mpoint
                    if [ $? -eq 0 ]; then
                            umount $mpoint
                    fi
            done'

    post_unmount_command = '
            if [ -f /usr/bin/net ]; then
                    sudo /usr/bin/net usershare delete "$(basename "%mount_point")"
            fi'
}

I do hope that the OSMC developers will turn their attention to this matter at some point in the future and propose an elegant solution to replace this rather ugly band-aid solution.