@84773 wrote:
There are a few ways of determining which usb is plugged into which port.
One way is to determine the usb controller based number when plugging the usb in, then inspecting the details of the physical location in the /sys directory.
To do it this way, run in a terminal:
*(See below for how to run it as user rather than root, if you wish to do that)
Then plug the usb in, and observe the output on the terminal screen. The following sort of output appears pretty much immediately:
Code:
[49881.113615] usb 1-6: new high-speed USB device number 9 using xhci_hcd
[49881.262768] usb 1-6: New USB device found, idVendor=0781, idProduct=55a1, bcdDevice= 1.00
[49881.262784] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[49881.262789] usb 1-6: Product: Cruzer Spark
[49881.262793] usb 1-6: Manufacturer: SanDisk
[49881.262797] usb 1-6: SerialNumber: 03025011071521122934
[49881.266685] usb-storage 1-6:1.0: USB Mass Storage device detected
[49881.267682] scsi host9: usb-storage 1-6:1.0
[49882.271659] scsi 9:0:0:0: Direct-Access SanDisk Cruzer Spark 1.00 PQ: 0 ANSI: 6
[49882.272261] sd 9:0:0:0: Attached scsi generic sg1 type 0
[49882.273188] sd 9:0:0:0: [sda] 30031872 512-byte logical blocks: (15.4 GB/14.3 GiB)
[49882.274602] sd 9:0:0:0: [sda] Write Protect is off
[49882.274619] sd 9:0:0:0: [sda] Mode Sense: 43 00 00 00
[49882.274997] sd 9:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[49882.297398] sda: sda1
[49882.297790] sd 9:0:0:0: [sda] Attached SCSI removable disk
The output shows the usb controller details for this usb are: 1-6:1.0.
To close the dmesg output, press: cntl+c.
Navigate to the system details as follows for this bus controller:
Code:
cd /sys/bus/usb/devices/1-6:1.0/physical_location
List the files at the directory named "physical_location":
Code:
[tom@min /sys/bus/usb/devices/1-6:1.0/physical_location]$ ls -al
total 0
-r--r--r-- 1 root root 4.0K Apr 22 20:43 dock
-r--r--r-- 1 root root 4.0K Apr 22 20:43 horizontal_position
-r--r--r-- 1 root root 4.0K Apr 22 20:43 lid
-r--r--r-- 1 root root 4.0K Apr 22 20:43 panel
-r--r--r-- 1 root root 4.0K Apr 22 20:43 vertical_position
Then you can interrogate each file with the cat command to tell you where the port is, like as follows:
Code:
[tom@min /sys/bus/usb/devices/1-6:1.0/physical_location]$ cat dock
no
[tom@min /sys/bus/usb/devices/1-6:1.0/physical_location]$ cat horizontal_position
left
[tom@min /sys/bus/usb/devices/1-6:1.0/physical_location]$ cat lid
no
[tom@min /sys/bus/usb/devices/1-6:1.0/physical_location]$ cat panel
top
[tom@min /sys/bus/usb/devices/1-6:1.0/physical_location]$ cat vertical_position
upper
The result is that the usb port has been identified on this box. No other usb port will have these physical locations.
*If the dmesg command asks to be run by root (which is often the default), and you wish to run the command as user, you can alter that to allow the user to run it by running the following as root:
Code:
echo 0 > /proc/sys/kernel/dmesg_restrict
Then, to update the system, run as root: