Have you worked with USB serial devices on Linux? One annoyance you may have come across is device name changes after each reboot. This problem gets solved by binding a custom /dev name to a USB device. This post shows you how.

To be clear, this article walks through assigning USB serial devices persistent names. If you have a USB block device and would like to give it a persistent name, the ArchWiki1 has you covered.

USB Serial Device Name Binding Using udev

The instructions below will work on a Linux distro that uses udev2 for device management. You will need root privileges to follow these instructions!

  1. Plugin the USB serial device.
  2. Identify the /dev/ttyUSB* name assigned to your device. There are many ways to do this. Perhaps the easiest is to grep the dmesg log to see what name the kernel gives the device:
dmesg | grep USB
  1. List the device attributes using udevadm. Replace <X> with the USB number found in step 2:
udevadm info --name=/dev/ttyUSB<X> --attribute-walk
  1. You’ll see a list of attributes for your device on the console. Find one or more attributes that uniquely identify your device. The combination of vendor ID and product ID is a good choice.
  2. Create or edit the /etc/udev/rules.d/99-usb-serial.rules file to include an entry like the one shown below. Be sure to input your own attributes and set SYMLINK to the name you’d like the device to have.
SUBSYSTEM=="tty", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", SYMLINK+="mydevice"
  1. Load the new rules using udevadm:
udevadm trigger
  1. Verify the USB serial device has its new name:
ls -l /dev/mydevice
  1. On reboot or when you plugin the device, the new name will persist.

To bind more device names, simply add rules to 99-usb-serial.rules. To undo these changes, delete the device’s corresponding rule in /etc/udev/rules.d/99-usb-serial.rules and run udevadm trigger.

  1. “Persistent block device naming” ↩︎

  2. The udev Wikipedia page gives a nice overview of the history and purpose of the tool. ↩︎