USB devices no longer show up in /dev

As of this week (?), dynamically plugged usb devices no longer show in /dev.

Setup:

  • multi-container app
  • Dockerfile for affected container sets “ENV UDEV=1” and does not override the ENTRYPOINT
  • It is run as “privileged”

When I connect a USB device (example is an ESP32 but I’ve tried many others with same result), it shows up in lsusb:

Bus 001 Device 005: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP2102/CP2109 UART Bridge Controller [CP210x family]

dmesg even shows the port the device is attached to (ttyUSB0):

[  472.505837] usbcore: registered new interface driver cdc_acm
[  588.133495] usb 1-1.4: new full-speed USB device number 5 using xhci_hcd
[  588.244833] usb 1-1.4: New USB device found, idVendor=10c4, idProduct=ea60, bcdDevice= 1.00
[  588.253373] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  588.260848] usb 1-1.4: Product: CP2104 USB to UART Bridge Controller
[  588.267342] usb 1-1.4: Manufacturer: Silicon Labs
[  588.272167] usb 1-1.4: SerialNumber: 0160B5B8
[  588.540347] usbcore: registered new interface driver cp210x
[  588.546444] usbserial: USB Serial support registered for cp210x
[  588.564967] usb 1-1.4: cp210x converter now attached to ttyUSB0

If I plug in a second device, dmesg reports cp210x converter now attached to ttyUSB1.

However, neither list in /dev.

Possibly relevant is a recent change to no longer run the container as root, i.e. added

RUN useradd -m -s /bin/bash -G dialout,netdev -U -u 1000 iot \
 && echo 'iot ALL=(ALL) NOPASSWD:ALL' | EDITOR='tee -a' visudo

USER iot
WORKDIR /home/iot

CMD [ "/bin/bash", "/usr/local/bin/start.sh" ]

Maybe this “broke” the usb mount - if so, what’s the fix?

Yes, switching to a non-root user was the problem. Making the switch in start.sh instead fixed my issue.

I suspect the ENTRYPOINT script assumes the user is root.

Thanks for reaching out. It seems from your message you were able to resolve the issue via switching in start.sh. Anything we can help here answer for you?

Hi, are you still having issues accessing your USB devices? Let us know if there are still things that you need help with.

Everything works again after removing “USER iot” from my Dockerfile.
Perhaps this could be added to the documentation:

  • Privileged
  • UDEV=1
  • → add USER root

I switch the user in start.sh (run by CMD). The trick is to avoid inadvertently dropping back to root (exit, ^D).

Many thanks! I should say generally my experience with Balena.io has been excellent. It’s powerful and very reliable. Thanks!