Hi all,
I´ve got a question regarding how USB-sticks behave when being inserted.
I noticed the following: whenever I insert a usb-stick into my Linux Lite PC it gets automatically mounted.
But for some particular reason I just want to exclude this one: /media/rosika/74C1-30C7
.
This is the path to it.
Any other usb-sticks should still be automatically mounted.
I did some research on the topic and came up with this possible solution:
I might set up a rule to prevent a specific USB stick from automatically mounting while still allowing others to mount normally.
I could achieve this by using udev rules.
With a custom udev rule, I should be able to specify exactly which devices should have automatic mounting disabled based on their unique properties, like their UUID.
- Identify Unique Properties of the USB Stick:
lsblk -o NAME,UUID,MOUNTPOINT
NAME UUID MOUNTPOINT
[...]
sdf 74C1-30C7 /media/rosika/74C1-30C7
[...]
So the relevant UUID is 74C1-30C7
.
- create the file:
sudo nano /etc/udev/rules.d/99-usb-no-automount.rules
Add the following rule to the file:
SUBSYSTEM=="block", ENV{ID_FS_UUID}=="74C1-30C7", ENV{UDISKS_AUTO}="0"
Here’s what each part does:
SUBSYSTEM==“block”: Targets block devices, like USB sticks.
ENV{ID_FS_UUID}==“74C1-30C7”: Matches the UUID of my specific USB stick.
ENV{UDISKS_AUTO}=“0”: Tells the system not to auto-mount this device.
sudo udevadm control --reload-rules
# reload udev-rules
That should (hopefully) do the trick.
For manually mounting the stick it´s most convenient to do it with thunar
, as it provides a GUI.
Otherwise:
sudo mount /dev/sdf /mnt/my-usb-stick
… provided that /dev/sdf
denotes the relevant stick and that /mnt/my-usb-stick
is the mount point.
What do you think
Is the setting up of the udev rule the correct way of achieving the task?
Thanks a lot and many greetings from Rosika