Sticking a USB-microcontroller on the port (similar to Arduino) creates these two files:


Are the ids in this case generated on the fly by a program or are they hardcoded somewhere on the device itself?

If it is created on the fly:

  1. How excactly is it created?
  2. Will it exist only on Linux machines?

2 Answers 2


The file name is generated by udev, but the id inside it comes from the device itself:

if you run lsusb -v and search for it, you'll find it's the serial id of the device:

iManufacturer        MBED
iProduct             microcontrolleur
iSerial              10105a42e87da33c103dccfb6bc235360a97

or something similar.

How does this happen ?

Let's say the usb stick gets mounted on /mnt/tmp. On my system i get:

$ udevadm info --device-id-of-file /mnt/tmp

Now run this and search for 8:17:

$ udevadm info --export-db | less
P: /devices/pci0000:00/0000:00:1d.7/usb1/1-3/1-3:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb1
N: sdb1
W: 61
S: block/8:17
S: disk/by-id/usb-pqi_IntelligentStick_AA04212900042956-0:0-part1

This gives us the device path to use with udevadm. Run this and search for for your device id (AA042... in my case)

$ udevadm test /devices/pci0000:00/0000:00:1d.7/usb1/1-3/1-3:1.0/host4/target4:0:0/4:0:0:0/block/sdb/sdb1 2>&1 | less
udev_rules_apply_to_event: LINK 'disk/by-id/usb-pqi_IntelligentStick_AA04212900042956-0:0-part1' /lib/udev/rules.d/60-persistent-storage.rules:31

That gives us all the udev rules + line numbers applied (60-persistent-storage.rules:31 etc)

And here's where the file name comes from:

$ /lib/udev/usb_id /devices/pci0000:00/0000:00:1d.7/usb1/1-3/1-3:1.0/host4/target4:0:0/4:0:0:0/block/sdb
  • The question is then how lsusb gets this info.. because it might use udev like udisks does.
    – Pithikos
    Nov 14, 2014 at 17:58
  • You can check the serial number really comes from the device itself by running ChipGenius under windows. Nov 14, 2014 at 18:30
  • as alex showed, udev just concatenates the serial id from the kernel into a larger string. lsusb or lsblk use the same serial id. there's no treachery going on. feel free to trust built-in ls commands; otherwise, what can you trust? Oct 21, 2015 at 19:55

by-id symlinks are created by udev rules (and are specific to OS'es using udev)

You can find the specific rules in /lib/udev/rules.d:

for serial devices in 60-persistent-serial.rules:

ENV{.ID_PORT}=="", SYMLINK+="serial/by-id/$env{ID_BUS}-$env{ID_SERIAL}-if$env{ID_USB_INTERFACE_NUM}"
ENV{.ID_PORT}=="?*", SYMLINK+="serial/by-id/$env{ID_BUS}-$env{ID_SERIAL}-if$env{ID_USB_INTERFACE_NUM}-port$env{.ID_PORT}"

and for the disk devices in 60-persistent-storage.rules:

KERNEL=="sd*|sr*|cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.