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

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.

1 Like