ENV vs ATTR/ATTRS
ATTR{filename}
Match sysfs attribute values of the event device.
ATTRS{filename}
Search the devpath upwards for a device with matching sysfs attribute values. If multiple ATTRS matches are specified, all of them must match on the same device.
ENV{key}
Match against a device property value.
If both ENV
and ATTR
contain the same information - you can use any of them, there is no any difference.
ENV
s for the device in question can contain values derived from different parent devices. So with ENV
s you can sometimes match on values from several parent devices simultaneously, which is impossible with ATTRS
.
Rule for creating a directory
You must use absolute path in RUN
key (RUN+="/bin/mkdir /home/pi/heyimhere"
in your example):
If no absolute path is given, the program is expected to live in /usr/lib/udev; otherwise, the absolute path must be specified.
By the way, I don't know why your shutdown rule works. It shouldn't, because of sbin/shutdown
without leading /
.
Mounting from udev rules
As jasonwryan mentioned, you can't use udev for automount:
Note that running programs that access the network or mount/unmount filesystems is not allowed inside of udev rules, due to the default sandbox that is enforced on systemd-udevd.service.
SYSTEMD_WANTS
; seeman systemd.device
.