I have a mobile phone connected to my PC via USB.

When viewing the device info using

sudo udevadm info --attribute-walk

the product and vendor id's show up fine, but there is no ATTR{serial}. An application I'm using (Android adb) needs the device to report a serial number to work properly.

Is there any way I can fake the serial number of the device, for example by using a udev rule?

Clarification: The question is not on how to get the serial number of the USB device, but on how to set the serial number.

I had an Android phone that does not report a serial number over USB, and the adb tool did not like this too much. So far there does not seem to be any simple solution for this. However, there days it is very easy to just buy a proper Android phone for development.

  • Is it an android phone? If not, adb will not work, anyway.
    – Keith
    Commented Dec 31, 2010 at 3:05
  • I'm guessing that adb doesn't actually get this info from udev. Probably from sysfs instead, or directly from the device. Consider patching adb, probably the easiest approach.
    – derobert
    Commented Jan 2, 2013 at 16:05

3 Answers 3


First, make sure that the device not reporting a serial number is really the problem. adb devices will list the serial number as all question marks if it doesn't have permission to access the corresponding device under /dev/bus/usb/. Also remember the adb starts up a server, you may need to kill that to get it to re-probe.

Assuming it really is a problem with the device, I quickly checked the adb source code. It appears register_device in core/adb/usb_linux.c reads the serial number straight from the device. core/adb/usb_libusb.c calls libusb_get_device_descriptor to do it, which (checking the libusb source code) grabs it from sysfs or directly from the device. So no udev trickery is going to help, unfortunately.

Your choices would seem to be:

  • figure out how to make adb work without a serial number. Possibly, patch adb (it is open source). This is a question more for Stack Overflow, I think.
  • patch to kernel usbfs driver to fake a response to adb's request. This sounds much harder than patching adb to me.
  • patch the kernel to allow faking the serial # in syfs, assuming adb is using libusb.
  • fix the broken hardware.
  • Thanks - this explains it. In my case fixing the broken hardware was the easier (buying better hardware).
    – Ralf
    Commented Jan 2, 2013 at 19:27

If you know the device node of the specific device (e.g. /dev/sdb), you can look it up with the following command: udevadm info -a -p $(udevadm info -q path -n /dev/sdb)

Usually, if you're trying to create a custom rule in /etc/udev/rules.d/51-android.rules for android devices, writing lsusb in your terminal will display something like Bus 002 Device 004: ID 062a:3270 Creative Labs . The four characters after "ID"--in this case it would be 062a--are used to indicate the specific idVendor within that file.

  • That helps with writing udev rules, but is there any way to write a rule that changes the serial number?
    – Ralf
    Commented Jan 2, 2013 at 15:38
  • Don't know for your particular phone, but in my experience once the udev rules are set (and you run adb start-server as root or using sudo), adb will be able to read the serial number on its own. Commented Jan 2, 2013 at 19:27

Probably it's not serial but FTDI, so you can try this way:

1) Get the serial

sudo udevadm info --attribute-walk -n /dev/ttyUSB0  | sed -n '/FTDI/,/serial/p'

2) Create the rule and substitute the XXXXXXXX with the serial you found or a FAKE serial

sudo echo 'SUBSYSTEM=="tty", ATTRS{serial}=="XXXXXXXX", GROUP="users", MODE="0660", SYMLINK+="myusbphone"' | sudo tee /etc/udev/rules.d/99-myusbphone.rules

3) Reload the rules

sudo udevadm control --reload-rules


In the case try to contact the author of this article.

  • I don't think OP is talking about serial protocol but the serial number of the USB device. That's a little used field in the device descriptor along with vendor and product IDs. It's supposed to be unique to each device but isn't mandatory in the USB spec. No answer for how to fake it, sorry. I'd probably patch the kernel...
    – ali1234
    Commented Apr 25, 2011 at 22:33

You must log in to answer this question.

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