Recognize more devices on Linux with this USB ID Repository

An open source project contains a public repository of all known IDs used in USB devices.
151 readers like this.
Testing Linux hardware compatibility with USB sticks

Opensource.com

There are thousands of USB devices on the market—keyboards, scanners, printers, mouses, and countless others that all work on Linux. Their vendor details are stored in the USB ID Repository.

lsusb

The Linux lsusb command lists information about the USB devices connected to a system, but sometimes the information is incomplete. For example, I recently noticed that the brand of one of my USB devices was not recognized. the device was functional, but listing the details of my connected USB devices provided no identification information. Here is the output from my lsusb command:

$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046d:082c Logitech, Inc. 
Bus 001 Device 003: ID 0951:16d2 Kingston Technology 
Bus 001 Device 002: ID 18f8:1486  
Bus 001 Device 005: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

As you can see in the last column, there is one device with no manufacturers description. To determine what the device is, I would have to do a deeper inspection of my USB device tree. Fortunately, the lsusb command has more options. One is -D device, to elicit per-device details, as the man page explains:

"Do not scan the /dev/bus/usb directory, instead display only information about the device whose device file is given. The device file should be something like /dev/bus/usb/001/001. This option displays detailed information like the v option; you must be root to do this."

I didn't think it was easily apparent how to pass the device path to the lsusb command, but after carefully reading the man page and the initial output I was able to determine how to construct it. USB devices reside in the UDEV filesystem. Their device path begins in the USB device directory /dev/bus/usb/. The rest of the path is made up of the device's Bus ID and Device ID. My non-descript device is Bus 001, Device 002, which translates to 001/002, and completes the path /dev/bus/usb/001/002. Now I can pass this path to lsusb. I'll also pipe to more since there is often quite a lot of information there:

$ lsusb -D /dev/bus/usb/001/002 |more
Device: ID 18f8:1486  
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x18f8 
  idProduct          0x1486 
  bcdDevice            1.00
  iManufacturer           0 
  iProduct                1 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           59
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              0 
        HID Device Descriptor:

Unfortunately, this didn't provide the detail I was hoping to find. The two fields that appear in the initial output, idVendor and idProduct, are both empty. There is some help, as scanning down a bit reveals the word Mouse. A-HA! So, this device is my mouse.

The USB ID Repository

This made me wonder how I could populate these fields, not only for myself but also for other Linux users. It turns out there is already an open source project for this: the USB ID Repository. It is a public repository of all known IDs used in USB devices. It is also used in various programs, including the USB Utilities, to display human-readable device names.

You can browse the repository for particular devices either from the website or by downloading the database. Users are also welcome to submit new data. This is what I did for my mouse, which was absent.

Update your USB IDs

The USB ID database is stored in a file called usb.ids. This location may vary depending on the Linux distribution.

On Ubuntu 18.04, this file is located in /var/lib/usbutils. To update the database, use the command update-usbids, which you need to run with root privileges or with sudo:

$ sudo update-usbids

If a new file is available, it will be downloaded. The current file will be backed up and replaced by the new one:

$ ls -la
total 1148
drwxr-xr-x  2 root root   4096 Jan 15 00:34 .
drwxr-xr-x 85 root root   4096 Nov  7 08:05 ..
-rw-r--r--  1 root root 614379 Jan  9 15:34 usb.ids
-rw-r--r--  1 root root 551472 Jan 15 00:34 usb.ids.old

Recent versions of Fedora Linux store the database file in /usr/share/hwdata. Also, there is no update script. Instead, the database is maintained in a package named hwdata.

# dnf info hwdata

Installed Packages
Name         : hwdata
Version      : 0.332
Release      : 1.fc31
Architecture : noarch
Size         : 7.5 M
Source       : hwdata-0.332-1.fc31.src.rpm
Repository   : @System
From repo    : updates
Summary      : Hardware identification and configuration data
URL          : https://github.com/vcrhonek/hwdata
License      : GPLv2+
Description  : hwdata contains various hardware identification and configuration data,
             : such as the pci.ids and usb.ids databases.

Now my USB device list shows a name next to this previously unnamed device. Compare this to the output above:

$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 046d:082c Logitech, Inc. HD Webcam C615
Bus 001 Device 003: ID 0951:16d2 Kingston Technology 
Bus 001 Device 014: ID 18f8:1486 [Maxxter] 
Bus 001 Device 005: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

You may notice that other device descriptions change as the repository is regularly updated with new devices and details about existing ones.

Submit new data

There are two ways to submit new data: by using the web interface or by emailing a specially formatted patch file. Before I began, I read through the submission guidelines. First, I had to register an account, and then I needed to use the project's submission system to provide my mouse's ID and name. The process is the same for adding any USB device.

Have you used the USB ID Repository? If so, please share your reaction in the comments.

What to read next
Alan Formy-Duval Opensource.com Correspondent
Alan has 20 years of IT experience, mostly in the Government and Financial sectors. He started as a Value Added Reseller before moving into Systems Engineering. Alan's background is in high-availability clustered apps. He wrote the 'Users and Groups' and 'Apache and the Web Stack' chapters in the Oracle Press/McGraw Hill 'Oracle Solaris 11 System Administration' book.

6 Comments

This sort of thing should be populated automatically without user input. If Linux is going to keep up as a desktop OS, it will have to collect some information. Let it be opt in for all the privacy types, but don't waste the opportunity. We're still getting our butts kicked. It's 2020 and HiDPI support is still a joke. We're the last to get everything and by a huge margin. We have to do better.

Note that just because you can update something manually on Linux doesn't mean you have to. This sort of data does get updated with major upgrades, without user input; this article is about how to update it before that happens. There's no OS that can keep up with every USB device released to market, and provide metadata about each device without some kind of external database to track them all. This is status quo.

In reply to by Bernard (not verified)

Interesting article ... But I can seem to find how to do this in Ubuntu 20.04
Any ideas?

JJ, It seems that Ubuntu distribution versions after 18.04 no longer use the script. Instead, the USB ID file is now maintained by the package "usb-ids". The following command will check for updates.

# apt --only-upgrade install usb.ids

The comments of the file do mention that the latest version can be obtained from http://www.linux-usb.org/usb.ids, so it is possible to manually update the file. I'll leave this with the obligatory "At your own risk" warning though.

Thanks for bringing this to our attention.

In reply to by JJ

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.