There is already a rules file (60-persistent-serial.rules
) that creates pretty paths in /dev/serial/by-path/
that match the port. For example, when my USB serial device got inserted in a USB 3.0 port:
$ ls -l serial/by-path/
total 0
lrwxrwxrwx 1 root root 13 Apr 2 22:20 pci-0000:02:00.0-usb-0:1:1.0-port0 -> ../../ttyUSB0
And when the same device is connected to a different USB 2.0 port:
$ ls -l /dev/serial/by-path/
total 0
lrwxrwxrwx 1 root root 13 Apr 2 22:20 pci-0000:00:1d.0-usb-0:1.2:1.0-port0 -> ../../ttyUSB0