Preventing USB flash drive auto mounting (/run/media/root)

Is there any way to prevent the USB flash drive auto mounting feature in /run/media/root?

I am working with an Apalis IMX6 and, although I have deleted the automount.rules file and created the file 12-prevention-automount.rules, the flash drive is automatically mounted in /run/media/root folder.

The problem arises when I mount the drive in a different place and try to change the permissions of that folder to let other user work with it; I can not change them until I have unmounted the drive from /run/media/root first

Is there a way to prevent this?

There are actually two mechanisms in the standard Toradex Linux image capable of automounting: udisks & a udev automount rule.

Disable the automount rule by removing (or moving) it:
rm /etc/udev/rules.d/automount.rules

Disable udisks automounting of USB drives by creating a new udev rule (e.g. /etc/udev/rules.d/12-prevent-automount.rules):

ACTION=="add|change", SUBSYSTEM=="block", KERNEL=="sd*", ENV{UDISKS_PRESENTATION_HIDE}="1"

Note that if you are using udisks2, the above will not work as UDISKS_PRESENTATION_HIDE is no longer supported. Instead, use UDISKS_IGNORE as follows:

ACTION=="add|change", SUBSYSTEM=="block", KERNEL=="sd*", ENV{UDISKS_IGNORE}="1"

this question is already answered here for udisks.