Linux – USB bus port number vs USB physical position

linuxusbusb device

I have multiple devices connected to 3 USB ports.

I can list them connected with some identification numbers through the following commands:

# cd /sys/bus/usb/drivers/usb
# ls
1-1     1-1.2   1-1.3   1-1.4   bind    uevent  unbind  usb1    usb2
# cat 1-1.2/product
My Connected Device

I want to put a label in the physical port of "My Connected Device" like "Connect Here". And I need to ensure that the following unbind/bind command can be sent only to that port to that specific device:

echo -n "1-1.2" > /sys/bus/usb/drivers/usb/unbind

If the hardware is the same, is it reliable to consider that after a reboot the system will always assign 1-1.2 to the same physical USB port?

Best Answer

As long as your USB hardware doesn't change (e.g: USB hubs, USB cards, etc), then yes, it is safe to assume that indeed the device will be assigned to the same location in /sys/bus/usb/devices/x-x.x. Linux should scan for and assign those x-x.x IDs in the same order every boot, however bear in mind that a device has to be connected to that port for that directory entry to exist.

Related Question