I need to run a script, when connecting a usb-drive to an embedded system. My idea was:
SUBSYSTEM=="block",ACTION=="add", KERNELS=="sd?",RUN+="/script param1 %k"
It needs to run with any usb-stick, so I am not able to use Vendor-specific parameters. Now the script executes with sd[a..][,1..], but it should only execute when sd[a..] connects (_ for NULL). With the ? it works when disconnecting, but on connecting, it executes for each partition Is there any possibility or do I habe to parse this in the Shell-Script?
Would be nice, if anyone could help me here. (If someone saw, that I deleted the Question: sorry, I thought, the ? was the final solution. But it didn work either).
Here is the output of udevadm info --attribute-walk -name /dev/sda1
looking at device '/devices/platform/fsl-ehci.1/usb1/1-1/1-1:1.0/host2/target2:0:0/2:0:0:0/block/sda/sda1':
KERNEL=="sda1"
SUBSYSTEM=="block"
DRIVER==""
ATTR{partition}=="1"
ATTR{start}=="63"
ATTR{size}=="1526112"
ATTR{alignment_offset}=="0"
ATTR{discard_alignment}=="4294935040"
ATTR{stat}==" 0 0 0 0 0 0 0 0 0 0 0"
ATTR{inflight}==" 0 0"
looking at parent device '/devices/platform/fsl-ehci.1/usb1/1-1/1-1:1.0/host2/target2:0:0/2:0:0:0/block/sda':
KERNELS=="sda"
SUBSYSTEMS=="block"
DRIVERS==""
ATTRS{range}=="16"
ATTRS{ext_range}=="256"
ATTRS{removable}=="1"
ATTRS{ro}=="0"
ATTRS{size}=="15656960"
ATTRS{alignment_offset}=="0"
ATTRS{discard_alignment}=="0"
ATTRS{capability}=="51"
ATTRS{stat}==" 1 0 8 4 0 0 0 0 0 4 4"
ATTRS{inflight}==" 0 0"