In Linux, Is there a way to remember/change a path to a USB device?
In my case, I need linux to remember that my USB serial adapter will stay on /dev/ttyUSB0, but when I unplug it and plug it back in, it switches to /dev/ttyUSB1.
I'm using a debian-based distro(mint), if that helps. Thanks!
Answer
Get to know properties of the device while it is switched in:
udevinfo -a -p $(udevinfo -q path -n /dev/ttyUSB0)
If you have some newer distribution where udevinfo is not available, use this instead:
udevadm info -q all -p $(udevadm info -q path -n /dev/ttyUSB0)
Find some property that can identify the device (uniquely), for instance "serial"
Create a file called /etc/udev/rules.d/10-usb-serial which contains the line:
BUS=="usb", ATTR{serial}=="xxxx", NAME="ttyUSB0"
Note the two equal signs for properties that are tested, and one for that which is assigned to.
No comments:
Post a Comment