1

I have several Lenovo machines with varying numbers of physical USB ports. I need to programmatically identify the number of physical USB ports on each machine. The operating system installed is Linux. These USB ports may be either empty or connected to USB devices.

Even a suggestion of an approach to take to resolve this would be really helpful.

2 Answers 2

2

You can't; the operating system only sees how many ports a hub IC has, not how many are connected to external USB ports.

5
  • what about lsusb? Commented Feb 20 at 21:06
  • My answer addresses exactly that, cinemassacres. lsusb can't report you something that it doesn't know. Commented Feb 20 at 21:14
  • LSB lists connected USB devices only, it doesn't list ports individually if there's nothing in them. Some of those devices are hubs, and you can see how many ports are on each "hub" but there's no way to tell if those hub ports correspond to a physical port, and I'm not even sure if you can tell if a hub is real or virtual or if a device listed in lsusb is real or virtual. So, like, it might list your camera as a usb device, but it's hardwired in,. Is that a USB port? Can't tell unless you look at a manifest for your specific laptop and match part numbers.
    – user10489
    Commented Feb 20 at 23:13
  • Doesn't each USB port have a unique identifier that we could use to determine its count? Commented Mar 1 at 12:03
  • If you mean the physical USB connectors: no, there's no ID on a passive connector. If you mean the logical ports on a USB hub / root controller: again, that doesn't tell you anything about whether that hub port is connected to an external connector. So, no, that doesn't help at all and has already been addressed in my answer! Commented Mar 1 at 12:28
1

You could get the information from their support center. There are no web services that I know of, but the html output is parsable. This is only for the computers the OP mentioned.

First get the serial number, as root, from /sys/devices/virtual/dmi/id/product_serial and then visit https://support.lenovo.com/qrcode/YOUR_SERIAL_NUMBER//qrcode_web and parse the result.

This works for me in an old Lenovo, as root, but you might have to tweak it:

# curl -sL "https://support.lenovo.com/qrcode/$(cat /sys/devices/virtual/dmi/id/product_serial)//qrcode_web" | grep -oE '"Description":"[^"]*"' | tr '•' '\n'|grep USB.*total
4 USB ports in the front, 8 USB ports in total\n
1
  • Machine with Serial No.: PG03NCT3 has 8 usb ports. But as per Lenovo specifications, it has 6 usb port only. Commented Mar 1 at 12:02

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .