whats wrong with this simple udev rule?
KERNEL=="sdc1", ACTION=="add", RUN+="/bin/mkdir /tmp/folder1"
When I plug in my USB-Stick the rule does nothing.
No, you may not able to create folder.
Because sd??
nodes are created by kernel before the partition get mounted.
Better to look for a different approach, example using a script with udisks
.
Use a rule with UUID matching:
KERNEL=="sd??", ENV{ID_FS_UUID}=="<the_uuid>", RUN+="/bin/mkdir /tmp/folder1"
get the UUID with the command below
udevadm info /dev/<usb_stick_partition> | grep ID_FS_UUID=
Example
$ udevadm info /dev/sda1 | grep ID_FS_UUID=
E: ID_FS_UUID=c44a008d-58b2-467d-8814-f06973e49dcb
therefore
KERNEL=="sd??", ENV{ID_FS_UUID}=="c44a008d-58b2-467d-8814-f06973e49dcb", RUN+="/bin/mkdir /tmp/folder1"
sdc1
?