I'm working on setting up a system where I want to have certain devices always named the same way when they are plugged into certain ports. I originally set up a udev rules file with the devices plugged directly into the computer. So I had rules like:
ACTION=="add", KERNEL=="<namePattern>", KERNELS=="7-3", SYMLINK+="<newName>"
7-3 specified a specific USB port on a PCI card in the computer (I figured out the numbers for each port using
udevadm info -q path -n <deviceName>).
However, I now need to plug the devices into a USB hub to allow them to be further away from the computer. When I plug the USB hub into that same port, it shows up under the number
4-5 instead of
7-3, which confuses me. So, devices plugged into the hub end up under numbers like
4-5.2 instead of
7-3.2 like I would have expected.
As I understand it, the first number before the dash indicates which USB bus the device is on, while the string of numbers after the dash indicate the port number for each successive hub that the device is plugged into. So, it doesn't make sense to me why those numbers would suddenly change to
4-5 when I plug a hub in when they've always been
7-3 for everything else I've plugged into that port. I would expect the earlier numbers to stay the same, but with an extra port number tacked on to the end to indicate that it's going through another USB hub.
Given that the first hub is numbered
4-5, the numbering does follow my expectations when I daisy chain a second hub in. I end up with devices under numbers like
4-5.3.x depending on which port on the first hub that I plug the second hub into. So, the
4-5 part stays the same, while the port numbers on the first and second hubs get tacked on.
I'm wondering why the first hub shows up with the number
4-5 instead of
7-3 like everything else plugged into that port? Apparently, I'm missing part of the understanding of how the numbering works in different situations.
Update: I played around with the system some more, and it turns out that the weird renumbering only happens when I plug the USB hub into one of the ports on the PCI card. When I plug it into the ports on the motherboard (or on front of the computer, which just goes to the mobo anyway), it keeps the same numbers as I would expect. I still don't understand why this would happen even with the PCI card, but at least the renumbering appears to be consistent. So, I can still set up rules that will work. If anyone has any good intuition on what's happening, I'm still curious to understand what's going on.