ACTION=="add", SUBSYSTEM=="block", RUN+="/bin/sh -c 'test -d /dev/hdd || mkdir /dev/hdd'" # some notes: # - you can't use SUBSYSTEM="usb" or you'll symlink to the parent devices (usb bus, hub...) # - otoh, if you symlink only on serial number, you override the symlink when /dev/sd.[0-9] kick in # - so you need both the SUBSYSTEM=="block", and the ENV{PARTN} # - (PARTN seems more reliable than ATTR{MINOR}/$minor, because more subdevices pop up) # - to grab a serial is supposed to be: udevadm info -a /dev/sdb | grep 'ATTRS{serial}' | head -n 1 # - this hasn't really been working for us; the serial returned isn't always what I get # - but this is the same as ENV{ID_SERIAL_SHORT}: smartctl -i /dev/sdb | grep Serial ACTION=="add", SUBSYSTEM=="block", ENV{ID_SERIAL_SHORT}=="BE1234567890", ENV{PARTN}=="", SYMLINK+="hdd/gdrive" ACTION=="add", SUBSYSTEM=="block", ENV{ID_SERIAL_SHORT}=="BE1234567890", ENV{PARTN}!="", SYMLINK+="hdd/gdrive$env{PARTN}" ACTION=="add", SUBSYSTEM=="block", ENV{ID_SERIAL_SHORT}=="7ACAB1312", ENV{PARTN}=="", SYMLINK+="hdd/toshiwhite" ACTION=="add", SUBSYSTEM=="block", ENV{ID_SERIAL_SHORT}=="7ACAB1312", ENV{PARTN}!="", SYMLINK+="hdd/toshiwhite$env{PARTN}" ACTION=="add", SUBSYSTEM=="block", ENV{ID_SERIAL_SHORT}=="0F1337BABE", ENV{PARTN}=="", SYMLINK+="hdd/toshiblack" ACTION=="add", SUBSYSTEM=="block", ENV{ID_SERIAL_SHORT}=="0F1337BABE", ENV{PARTN}!="", SYMLINK+="hdd/toshiblack$env{PARTN}" ACTION=="add", SUBSYSTEM=="block", ENV{ID_SERIAL_SHORT}=="575135461346432183132498", ENV{PARTN}=="", SYMLINK+="hdd/wdred" ACTION=="add", SUBSYSTEM=="block", ENV{ID_SERIAL_SHORT}=="575135461346432183132498", ENV{PARTN}!="", SYMLINK+="hdd/wdred$env{PARTN}" # uncomment to debug # ACTION=="add", SUBSYSTEM=="block", RUN+="/bin/sh -c '(echo ---; env) >> /tmp/udev.env.sh'" # vim: ft=udevrules