Static USB device name

When a device name is important (e.g. a line printer device such as /dev/usb/lp1), the
name could cause problems when multiple devices could change the device name sequence
at boot time or when devices are plugged or unplugged. The UDEV subsystem provides
a way to statically name these devices or symlinks to it.

It is recommended to specify static symlinks rather than device names in order to
avoid blocking adding devices if names already exists.

In modern versions of Linux, udev rules replaces the need for usb_modeswitch. In stead
if editing files in /etc/usb_modeswitch.d, you have to add configurations in
/etc/udev/rules.d.

  • Find the USB vendor and product IDs
  •       lsusb
          # or if you cannot recognise the USB device, but you know the current device name
          udevadm info -a -p  $(udevadm info -q path -n /dev/usb/lpX) | grep -B 3 -A 3 idVendor
          # Replace /dev/usb/lpX with the actual device number
        
  • Add a UDEV device ADD rule by editing /etc/udev/rules.d/10-local.rules and adding the following:
  •       ACTION=="add", ATTRS{idVendor}=="1504", ATTRS{idProduct}=="003d", SYMLINK+="pos"
          # Change vendor, product and name of symlink
          # In this example, plugging in a POS printer creates a device symlink /dev/pos
        
  • Refresh UDEV rules without rebooting
  •       udevadm control --reload-rules
          udevadm trigger
        
  • Unplug the device, wait a few seconds and plug it in again
  • Verify that symlink exists
  • Change application configuration
  •       # For example, change CUPS printer
          service cups stop
          # Edit /etc/cups/printers.conf and change the line printer device URL to your symlink:
          # e.g. DeviceURI parallel:/dev/pos
          service cups start
        

References:

http://www.reactivated.net/writing_udev_rules.html#external-naming
https://unix.stackexchange.com/questions/66901/how-to-bind-usb-device-under-a-static-name
https://unix.stackexchange.com/questions/39370/how-to-reload-udev-rules-without-reboot