Wednesday 6 February 2019

Linux: Remember path to USB Device


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





  1. 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)




  2. Find some property that can identify the device (uniquely), for instance "serial"




  3. 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

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...