phithor Posted May 3, 2018 Share Posted May 3, 2018 (edited) Hi, I am trying to run flightradar24 data feeder with a USB dongle. I successfully connect to the dongle with device number, example: /dev/bus/usb/001/012. However, this location changes after a few hours to the next available spot, i.e. /dev/bus/usb/001/013. This happens after a few hours every time the image is started. Any clues to how or why this can happen? Thanks Edited May 3, 2018 by phithor Quote Link to comment
aeleos Posted May 28, 2018 Share Posted May 28, 2018 (edited) You need to set up a persistent name for the usb device based on its usb-id. There is a tutorial for doing that here http://hintshop.ludvig.co.nz/show/persistent-names-usb-serial-devices/ You will also probably need to figure out how to get unraid to regenerate the udev rules every reboot. Edited May 28, 2018 by aeleos 2 Quote Link to comment
phithor Posted August 3, 2018 Author Share Posted August 3, 2018 (edited) For any other looking to do the same: 1. To see usb devices: lsusb 2. Found the one, for me: /dev/bus/usb/001/004, 0bda:2838 (flightradar DVB-T dongle) 3. Ran code to get serial number: udevadm info -a -n /dev/bus/usb/001/004 | grep '{serial}' | head -n1 Response: ATTR{serial}=="00000001" 4. Added new file in /etc/udev/rules.d: 99-usb-rules.rules with content: vi /etc/udev/rules.d/99-usb-rules.rules SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2838", ATTRS{serial}=="00000001", SYMLINK+="flightradar" 5. To get this to persist through reboots i copied the files to /boot/config/rules.d/99-usb-rules.rules: cp /etc/udev/rules.d/99-usb-rules.rules /boot/config/rules.d/99-usb-rules.rules 6. Then in the file /boot/config/go i added a command to copy it back on boot: vi /boot/config/go Add: cp /boot/config/rules.d/99-serial-rules.rules /etc/udev/rules.d/99-serial-rules.rules chmod 644 /etc/udev/rules.d/99-serial-rules.rules (not sure if it is required but it the permissions now match the other files in the folder) Not sure if this is run before usb is initialized, so you might have to reinsert the device after boot to get the symlink recognized. I will test it and report. EDIT: Seems like it is not recognized on boot. EDIT2: It is working! Edited August 8, 2018 by phithor 1 1 Quote Link to comment
MindRazorblade Posted August 4, 2018 Share Posted August 4, 2018 No luck for me either. I've just tried this too using User Scripts to execute the copy of these rules from my boot USB at disk startup just like you've done with go. I can confirm that the right file is in the right place according to the tutorial linked in aeleos. I wonder if the copy doesn't happen early enough in startup and the rules have already been run by the time they get copied. If anyone else has had luck doing this, please let us know. Quote Link to comment
MindRazorblade Posted August 5, 2018 Share Posted August 5, 2018 With a little bit of studying and experimentation I got this to work but I'm sure someone more experienced with udev would get this better I used the "User Scripts" app to setup a startup script that copies and refreshes the rules for the device so that the rules you setup in "99-usb-rules.rules" are loaded properly. Here it is: #!/bin/bash # copy persistent script from usb drive to drive at startup cp /boot/config/userFiles/99-usb-serial.rules /etc/udev/rules.d/ chmod 644 /etc/udev/rules.d/99-usb-serial.rules # udav has likely run before the copy completes so udev needs its rules refreshed udevadm control --reload-rules # a reset of the device is needed so the rules just copied can take hold udevadm trigger --attr-match=subsystem=tty I'm a little nervous about the last line resetting all tty subsystems since I wasn't able to get something like : udevadm trigger --attr-match=serial=0000:00:11.0 to work for some reason after confirming the serial with: udevadm info -a -n /dev/ttyUSB1 | grep '{serial}' | head -n1 Here are some links for education: http://hintshop.ludvig.co.nz/show/persistent-names-usb-serial-devices/ https://www.thegeekdiary.com/beginners-guide-to-udev-in-linux/ http://reactivated.net/writing_udev_rules.html https://unix.stackexchange.com/questions/39370/how-to-reload-udev-rules-without-reboot http://www.reactivated.net/writing_udev_rules.html#example-printer https://askubuntu.com/questions/445735/why-do-my-udev-rules-run-if-i-use-udevadm-trigger-but-not-at-boot-time/635477 https://www.linux.com/news/udev-introduction-device-management-modern-linux-system If you run into any commands that look like they're aren't installed be conscious that udev changed a bit since some of these were written and there are new commands for these (e.g. udevadm info instead of udevinfo). 2 Quote Link to comment
phithor Posted August 8, 2018 Author Share Posted August 8, 2018 It seems to be working! It did not work at first but tested it again now and it is working. Great. Quote Link to comment
Technikte Posted December 6, 2018 Share Posted December 6, 2018 On 8/5/2018 at 4:14 AM, MindRazorblade said: With a little bit of studying and experimentation I got this to work but I'm sure someone more experienced with udev would get this better I used the "User Scripts" app to setup a startup script that copies and refreshes the rules for the device so that the rules you setup in "99-usb-rules.rules" are loaded properly. Here it is: #!/bin/bash # copy persistent script from usb drive to drive at startup cp /boot/config/userFiles/99-usb-serial.rules /etc/udev/rules.d/ chmod 644 /etc/udev/rules.d/99-usb-serial.rules # udav has likely run before the copy completes so udev needs its rules refreshed udevadm control --reload-rules # a reset of the device is needed so the rules just copied can take hold udevadm trigger --attr-match=subsystem=tty I'm a little nervous about the last line resetting all tty subsystems since I wasn't able to get something like : udevadm trigger --attr-match=serial=0000:00:11.0 to work for some reason after confirming the serial with: udevadm info -a -n /dev/ttyUSB1 | grep '{serial}' | head -n1 Here are some links for education: http://hintshop.ludvig.co.nz/show/persistent-names-usb-serial-devices/ https://www.thegeekdiary.com/beginners-guide-to-udev-in-linux/ http://reactivated.net/writing_udev_rules.html https://unix.stackexchange.com/questions/39370/how-to-reload-udev-rules-without-reboot http://www.reactivated.net/writing_udev_rules.html#example-printer https://askubuntu.com/questions/445735/why-do-my-udev-rules-run-if-i-use-udevadm-trigger-but-not-at-boot-time/635477 https://www.linux.com/news/udev-introduction-device-management-modern-linux-system If you run into any commands that look like they're aren't installed be conscious that udev changed a bit since some of these were written and there are new commands for these (e.g. udevadm info instead of udevinfo). First thanks for your script. *Thumbs up* The other thing..I tried to get it succesfully running using UserScript (StartUp at first Array start) but didnt survived any reboot until I noticed that you are resting tty but I use SUBSYSTEM=="usb" so the correct syntax for this thread would be. udevadm trigger --attr-match=subsystem=usb A short info in your post would have saved me 2 hours. :D Quote Link to comment
Technikte Posted December 6, 2018 Share Posted December 6, 2018 Another question got me now. I have an other device an aeotec usb zwave adapter thing. I think it prestend in /dev as "ttyACM0" but not quite sure. So how to definde this device in the SUBSYSTEM=="???", part ? I have tried already SUBSYSTEM=="ttyACM", but got nothing. Quote Link to comment
CarlaTuck Posted February 6, 2019 Share Posted February 6, 2019 (edited) Hi...what I would do is to go to the manufacturers web site and download a driver for that device, for Windows 10, for the same arch as your VM. Some Windows device files have their own install program. If it has it's own install application, it will usually also look to see if it can see that device connected. Sometimes there are Single Board computers and PCB assembly for such board is really great. For those boards you need not to install any separate drivers. Edited December 8, 2021 by CarlaTuck Quote Link to comment
Zoba Posted January 21, 2020 Share Posted January 21, 2020 On 8/3/2018 at 8:55 AM, phithor said: 5. To get this to persist through reboots i copied the files to /boot/config/rules.d/99-usb-rules.rules: cp /etc/udev/rules.d/99-usb-rules.rules /boot/config/rules.d/99-usb-rules.rules I had to mkdir /boot/config/rules.d - anything else worked as you said! Thanks for the precise instruction Quote Link to comment
Greyberry Posted April 14, 2020 Share Posted April 14, 2020 Halleluja it is working! This was a real pain. As you mentioned the udev-rules run before or after the "/boot/config/go" script. Seems that this depends on each case and therefore is a prime example of a race-condition. The developers should have a look at this IMHO. I attached the trigger command directly to the boot script, saving the "User Scripts" App. My "/boot/config/go" : #!/bin/bash # Start the Management Utility /usr/local/sbin/emhttp & # add udev at boot cp /boot/config/rules.d/90-usb.rules /etc/udev/rules.d/90-usb.rules chmod 644 /etc/udev/rules.d/90-usb.rules udevadm trigger --attr-match=subsystem=tty The reload command was not necessary in my case. 🤷♂️ Quote Link to comment
polishprocessors Posted January 4, 2021 Share Posted January 4, 2021 Hey there-I've tried to reproduce this for my FlightAware USB device and I keep getting the following error: rtlsdr: error querying device #0: No such file or directory I think I've got it configured properly, as here's the lsusb/dev output: root@unRaid:/dev# ls -l flightradar lrwxrwxrwx 1 root root 15 Jan 4 16:50 flightradar -> bus/usb/001/023 root@unRaid:/dev# lsusb Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 003: ID 090c:1000 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) Flash Drive Bus 001 Device 023: ID 0bda:2832 Realtek Semiconductor Corp. RTL2832U DVB-T Bus 001 Device 005: ID 8087:0aaa Intel Corp. Bus 001 Device 004: ID 0b05:1872 ASUSTek Computer, Inc. AURA LED Controller Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub But the FW24 docker container won't start with /dev/flightaware as its RTL-SDR Device. I have the following script configured to run hourly: #!/bin/bash # copy persistent script from usb drive to drive at startup cp /boot/config/rules.d/99-usb-rules.rules /etc/udev/rules.d/ chmod 644 /etc/udev/rules.d/99-usb-rules.rules # udav has likely run before the copy completes so udev needs its rules refreshed udevadm control --reload-rules # a reset of the device is needed so the rules just copied can take hold udevadm trigger --attr-match=subsystem=usb Off this .rules config: root@unRaid:/etc/udev/rules.d# more 99-usb-rules.rules SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2832", ATTRS{serial}=="00001000", SYMLINK+="flightradar" Can anyone help point me in the right direction? I just don't seem able to to get this to work, even though it looks like it should be just fine to me... Quote Link to comment
spants Posted January 5, 2021 Share Posted January 5, 2021 for serial devices (such as my two 3d printers using octoprint), I just use the /dev/serial/by-id/@xxxxxxxxxx paths for them. Quote Link to comment
polishprocessors Posted January 6, 2021 Share Posted January 6, 2021 /dev/bus/usb doesn't support any by-id options-nothing obvious in there that should, hence the flightradar@ symlink, but that doesn't seem to work... Quote Link to comment
flamegrilled Posted January 7, 2021 Share Posted January 7, 2021 (edited) On 1/6/2021 at 2:46 PM, polishprocessors said: but that doesn't seem to work... usb2: usb to ethernet devices in a vm running opensense This is the log entry: -device usb-host,hostbus=1,hostaddr=3,id=hostdev0,bus=usb.0,port=1 \ -device usb-host,hostbus=2,hostaddr=6,id=hostdev1,bus=usb.0,port=2 \ -device usb-host,hostbus=2,hostaddr=7,id=hostdev2,bus=usb.0,port=3 \ The is the xml portion : <hostdev mode='subsystem' type='usb' managed='no'> <source> <vendor id='0x07a6'/> <product id='0x8515'/> <address bus='1' device='3'/> </source> <address type='usb' bus='0' port='1'/> </hostdev> <hostdev mode='subsystem' type='usb' managed='no'> <source> <vendor id='0x07a6'/> <product id='0x8515'/> <address bus='2' device='6'/> </source> <address type='usb' bus='0' port='2'/> </hostdev> <hostdev mode='subsystem' type='usb' managed='no'> <source> <vendor id='0x07a6'/> <product id='0x8515'/> <address bus='2' device='7'/> </source> <address type='usb' bus='0' port='3'/> </hostdev> The vm runs normally on a manual config and I see all 3 usb devices in opensense. root@Tower:/etc/udev/rules.d# cat 99-usb-rules.rules SUBSYSTEM=="usb", ATTRS{idVendor}=="07a6", ATTRS{idProduct}=="8515", ATTRS{serial}=="0001", SYMLINK+="ADMtek, Inc. AN8515 Ethernet" root@Tower:/boot/config/rules.d# cat 99-usb-rules.rules SUBSYSTEM=="usb", ATTRS{idVendor}=="07a6", ATTRS{idProduct}=="8515", ATTRS{serial}=="0001", SYMLINK+="ADMtek, Inc. AN8515 Ethernet" The go file : #!/bin/bash # Start the Management Utility /usr/local/sbin/emhttp & cp /boot/config/rules.d/99-usb-rules.rules /etc/udev/rules.d/99-usb-rules.rules chmod 644 /etc/udev/rules.d/99-usb-rules.rules udevadm trigger --attr-match=subsystem=tty Cannot get a persistent link to usb devices after a vm shutdown and startup. Got it working : The word symlink did not cross my mind... Had to read this : http://hintshop.ludvig.co.nz/show/persistent-names-usb-serial-devices/ a few times to figure I had to do this : renamed 99-usb-rules.rules to 99-usb-serial.rules and changed this : SUBSYSTEM=="usb", ATTRS{idVendor}=="07a6", ATTRS{idProduct}=="8515", ATTRS{serial}=="0001", SYMLINK+="ADMtek, Inc. AN8515 Ethernet" to this : root@Tower:/boot/config/rules.d# cat 99-usb-serial.rules SUBSYSTEM=="usb", ATTRS{idVendor}=="07a6", ATTRS{idProduct}=="8515", ATTRS{serial}=="0001", SYMLINK+="ADMtek0" SUBSYSTEM=="usb", ATTRS{idVendor}=="07a6", ATTRS{idProduct}=="8515", ATTRS{serial}=="0001", SYMLINK+="ADMtek1" SUBSYSTEM=="usb", ATTRS{idVendor}=="07a6", ATTRS{idProduct}=="8515", ATTRS{serial}=="0001", SYMLINK+="ADMtek2" Now have to figure out which one comes first in order to get the ethernet to be in the right order i.e. WAN,LAN,OPT1 Not solved : Usb to mac address issue need to resolve : https://github.com/eborisch/ethname Edited January 8, 2021 by flamegrilled ethernet address Quote Link to comment
Rick_Sanchez Posted January 9, 2021 Share Posted January 9, 2021 (edited) I've run through the steps here and am having some issues, wondering if anyone can spot a problem. I have /boot/config/rules.d/99-usb-rules.rules with the file SUBSYSTEM=="tty", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="1234", ATTRS{serial}=="myserial1", SYMLINK+="zigbee" SUBSYSTEM=="tty", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="1234", ATTRS{serial}=="myserial2, SYMLINK+="zwave" I have the UserScripts addon set to start 'At First Array Start Only' #!/bin/bash # add this to UserSctipt - StartUp at first Array start # Start the Management Utility /usr/local/sbin/emhttp & # copy persistent script from usb drive to drive at startup cp /boot/config/rules.d/99-usb-rules.rules /etc/udev/rules.d/ chmod 644 /etc/udev/rules.d/99-usb-rules.rules # udav has likely run before the copy completes so udev needs its rules refreshed udevadm control --reload-rules # a reset of the device is needed so the rules just copied can take hold udevadm trigger --attr-match=subsystem=tty Please note -- I added both the Start Management Utility and Reload rules parameters. Not sure if I require both. Script output at start of array: Script Starting Jan 09, 2021 06:33.01 Full logs for this script are available at /tmp/user.scripts/tmpScripts/99-usb-rules/log.txt emhttpd is already started Script Finished Jan 09, 2021 06:33.01 Full logs for this script are available at /tmp/user.scripts/tmpScripts/99-usb-rules/log.txt On reboot of my system and start of array: there are no USB devices listed in /dev/ - they are usually listed as /dev/ttyUSB0 and /dev/ttyACM0. Unplugging and plugging back the USB devices gets them recognized. the devices ARE recognized with lsusb in terminal BEFORE unplugging and plugging back in Edited January 9, 2021 by Rick_Sanchez Clarification Quote Link to comment
Waldo Posted January 8, 2022 Share Posted January 8, 2022 I was able to add the symlink using the info in this thread, but the docker container was not able to find the device when using the Add a Device parameter. I was able to work around it by adding the device in Extra Parameters in the Advanced View though. --device=$(readlink -f /dev/symlinkname) Quote Link to comment
christ777 Posted December 18, 2022 Share Posted December 18, 2022 (edited) On 1/8/2022 at 2:54 AM, Waldo said: I was able to add the symlink using the info in this thread, but the docker container was not able to find the device when using the Add a Device parameter. I was able to work around it by adding the device in Extra Parameters in the Advanced View though. --device=$(readlink -f /dev/symlinkname) I had the same issues, the container was not able to find the device ( a RTL-SDR USB radio for reading 433mhz devices in Home Assistant) when using the device parameter. However, adding the --device=$(readlink -f /dev/symlinkname) to the Extra Arguments were very unreliable. Sometimes the container could access the USB through the symlink and most of the times it could not. I changed to the -e option and it worked flawlessly: --device=$(readlink -e /dev/rtlsdr) # Change "rtlsdr" to your symlink name I also noticed the user scripts function "At first Array start only" was not working reliably either. Instead I added it to the /boot/config/go file: #Add udev rules cp /boot/config/rules.d/99-usb-rules.rules /etc/udev/rules.d/99-usb-rules.rules chmod 744 /etc/udev/rules.d/99-usb-rules.rules udevadm trigger --attr-match=subsystem=usb This is what I put into the /boot/config/rules.d/99-usb-rules.rules file. The name of this file is not important just that the filename begins with a large number, in this case 99, because the udev rules gets executed in order. So depending on what udev rules you have on your system you can name it 99-yourname.rules. SUBSYSTEM=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2838", MODE="0666", SYMLINK+="rtlsdr" # Change "rtlsdr" to your preferred symlink name Now it survive reboots, it is working reliably every time and I do not have to unplug/replug it to get it to recognize the device. Edited December 18, 2022 by christ777 Quote Link to comment
TRusselo Posted February 2, 2023 Share Posted February 2, 2023 (edited) the best method to passthrough usb to docker is via device by-id open unraid terminal type ls -l /dev/serial/by-id you will get output of your devices with names copy the whole BLUE name of your device go to your docker and edit config add /dev/serial/by-id/ before pasting the name from above. eg /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_dcf756dbb712ec118bca20c7bd930c07-if00-port0 then add :/dev/zigbee to the end - this is the container mount point so you end up with this in your Docker Host config: /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_dcf756dbb712ec118bca20c7bd930c07-if00-port0:/dev/zigbee if anywere inside your docker program it asks for the device location you would set it to : /dev/zigbee Edited February 19, 2023 by TRusselo Quote Link to comment
gambler3k Posted February 8, 2023 Share Posted February 8, 2023 On 2/2/2023 at 6:59 PM, TRusselo said: the best method to passthrough usb to docker is via device by-id open unraid terminal type ls -l /dev/serial/by-id you will get output of your devices with names copy the whole BLUE name of your device go to your docker and edit config add /dev/serial/by-id/ before pasting the name from above. eg /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_dcf756dbb712ec118bca20c7bd930c07-if00-port0 Tried this with my conbee2 stick and no luck. this in zigbee2mqtt configuration.yaml and i get this in zigbee2mqtt log so frustrating having to reconfig every time i reboot server Quote Link to comment
TRusselo Posted February 16, 2023 Share Posted February 16, 2023 (edited) On 2/8/2023 at 1:57 PM, gambler3k said: Tried this with my conbee2 stick and no luck. so frustrating having to reconfig every time i reboot server i have an idea docker config (your first screenshot) add :/dev/deconz to the end (this sets the mountpoint inside the docker {outside:inside}/ or {host:docker} ) so "/dev/serial/by-id/usb-dresden....97-if00:/dev/deconz" in configuration.yaml change port to serial: port: /dev/deconz Edited February 19, 2023 by TRusselo Quote Link to comment
gambler3k Posted February 18, 2023 Share Posted February 18, 2023 On 2/16/2023 at 10:51 PM, TRusselo said: if the previous post dont work... i have an idea docker config (your first screenshot) add :/dev/deconz to the end (this sets the mountpoint inside the docker {outside:inside}/ or {host:docker} ) so "/dev/serial/by-id/usb-dresden....97-if00:/dev/deconz" in configuration.yaml change port to serial: port: /dev/deconz thnx m8, this worked!! the first u suggested with "null" did not work fyi did the same with my zwavejs2mqtt docker and that seems to work also! 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.