~/Blog

Brandon Rozek

Photo of Brandon Rozek

PhD Student @ RPI studying Automated Reasoning in AI and Linux Enthusiast.

Custom Device Paths with UDEV rules

Published on

Updated on

Warning: This post has not been modified for over 2 years. For technical posts, make sure that it is still relevant.

I wanted to create a rule so that when I plug in my rtlsdr, a symlink to the device will appear in /dev/rtlsdr.

To do this, first we need to get some uniquely identifying information about the SDR.

❯ lsusb
Bus 001 Device 002: ID 8087:8001 Intel Corp. Integrated Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 017: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-T
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The part we care about here is the ID field. It is structured as ID vendor:product.

Now we can create a UDEV rule in /etc/udev/rules.d/ that says “when we see this specific USB plugged in, create a symlink called rtlsdr

(/etc/udev/rules.d/rtlsdr.rules)

SUBSYSTEM=="usb", ATTR{idVendor}=="0bda", ATTR{idProduct}=="2838", SYMLINK+="rtlsdr"

Tell udev to reload its rules

sudo udevadm control --reload

Now once you have your device plugged in, you should be able to see it under /dev/rtlsdr or whatever you specified your symlink as.

Reply via Email Buy me a Coffee
Was this useful? Feel free to share: Hacker News Reddit Twitter

Published a response to this? :