Home » Questions » Computers [ Ask a new question ]

Prevent a partition on a USB drive auto-mounting in Linux

Prevent a partition on a USB drive auto-mounting in Linux

On Linux (Gnome desktop) how do you prevent one of the partitions on an external USB drive auto-mounting when it attached to the machine?

Asked by: Guest | Views: 71
Total answers/comments: 1
Guest [Entry]

"At first, run udisksctl status to get the device path, followed by eg. udevadm info --attribute-walk --name=/dev/sr0, to get the characteristics of the USB device to ignore.
Then add a rule with UDISKS_IGNORE into /etc/udev/rules.d/12-prevent-automount.rules. For example, this blocks the ""HiSuite"" ""Linux File-CD Gadget"" of a Huawei Matepad Pro 12.6"", as the Windows software is rather irrelevant - and it's mount notifications are just as irrelevant:
ACTION==""add|change"", SUBSYSTEM==""block"", KERNEL==""sr[0-9]*"", ATTRS{model}==""File-CD Gadget "", ENV{UDISKS_IGNORE}=""1""

Then reload the rules with: udevadm control --reload-rules && udevadm trigger.
For testing the rule: udevadm monitor --environment --udev"