website/content/blog/customudev.md

1.2 KiB
Raw Blame History

title date draft tags medium_enabled
Custom Device Paths with UDEV rules 2020-11-10T20:58:37-05:00 false
Linux
true

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.