Missing /dev/serial/by-id on Debian variants.
Fix for missing /dev/serial/by-id on recent Debian derivatives due to a break in systemd.
Recently I rebuilt my 3D Printer’s Klipper environment setup which is powered via a couple of Udoo x86 SBCs that run DietPi for x86_64.
As Klipper talks to the MCU via USB, one needs to find the printer (or device) specific serial port and the easiest way is to get the path via /dev/serial/by-id
.
The problem
However, Debian 13 (Bookworm) didn’t have /dev/serial/by-id
available which I thought was unusual.
Digging into this, there’s a PR25246: udev: fix by-id symlinks by @yuwata from November 2022 for systemd that updates the 60-serial.rules configuration that broke the path from being created. However this fix hasn’t made it’s way into the later Debian releases it seems.
The Fix
The easiest way to fix this locally - knowing it will break in the future if you update your system and the file is overwritten, is to simply apply the changes in the change to your Debian source.
Backup your existing 60-serial.rules
file:
Then replace it with the PR’s changes:
Github Raw:60-serial.rules
Get the full raw output from Github Raw: 60-serial.rules.
Once done, you can reload the rules with:
You’ll find the /dev/serial/by-id/
will have been created and mapped appropriately now :)
Why is this important?
Example, for the following lsusb
fragment:
We have the following devices listed - /dev/serial/by-path
:
But ideally, we’d want to know their unique-id - /dev/serial/by-id
:
As the ID above is what we’d be saving in the printer.cfg
for Klipper.
[mcu]
serial: /dev/serial/by-id/usb-Klipper_stm32f407xx_43002E000451323333353137-if00
restart_method: command
...