How To Share USB Devices Over IP Using A Raspberry Pi

Поделиться
HTML-код
  • Опубликовано: 28 окт 2024

Комментарии • 53

  • @TechTutorialsDavidMcKone
    @TechTutorialsDavidMcKone  2 года назад +7

    Raspberry Pi:
    Switch to root account
    su -
    Install software
    apt install usbip
    modprobe usbip_host
    echo 'usbip_host' >> /etc/modules
    List USB devices and note down the product/vendor
    usbip list -l
    Create start script
    nano /usr/sbin/usbip_start.sh
    #!/bin/bash
    usb1='0781:5567'
    usb2='0658:0200'
    /usr/sbin/usbip bind --$(/usr/sbin/usbip list -p -l | grep '#usbid='$usb1'#' | cut '-d#' -f1)
    /usr/sbin/usbip bind --$(/usr/sbin/usbip list -p -l | grep '#usbid='$usb2'#' | cut '-d#' -f1)
    Make this executable
    chmod +x /usr/sbin/usbip_start.sh
    Create stop script
    nano /usr/sbin/usbip_stop.sh
    #!/bin/bash
    usb1='0781:5567'
    usb2='0658:0200'
    /usr/sbin/usbip unbind --$(/usr/sbin/usbip list -p -l | grep '#usbid='$usb1'#' | cut '-d#' -f1)
    /usr/sbin/usbip unbind --$(/usr/sbin/usbip list -p -l | grep '#usbid='$usb2'#' | cut '-d#' -f1)
    killall usbipd
    Make this executable
    chmod +x /usr/sbin/usbip_stop.sh
    Create service
    nano /lib/systemd/system/usbipd.service
    [Unit]
    Description=usbip host daemon
    After=network.target
    [Service]
    Type=forking
    ExecStart=/usr/sbin/usbipd -D
    ExecStartPost=/bin/bash -c '/usr/sbin/usbip_start.sh'
    ExecStop=/bin/bash -c '/usr/sbin/usbip_stop.sh'
    [Install]
    WantedBy=multi-user.target
    systemctl --system daemon-reload
    systemctl enable usbipd.service
    systemctl start usbipd.service
    Check what USB devices are found
    usbip list -p -l
    ---
    Linux Client
    Switch to root account
    su -
    Check USB device is attached
    lsusb
    Install software and create a service
    apt install usbip hwdata usbutils -y
    modprobe vhci-hcd
    echo 'vhci-hcd' >> /etc/modules
    Create start script
    nano /usr/sbin/usbip_start.sh
    #!/bin/bash
    server1='192.168.200.7'
    usb1='0781:5567'
    usb2='0658:0200'
    /usr/sbin/usbip attach -r $server1 -b $(/usr/sbin/usbip list -r $server1 | grep $usb1 | cut -d: -f1)
    /usr/sbin/usbip attach -r $server1 -b $(/usr/sbin/usbip list -r $server1 | grep $usb2 | cut -d: -f1)
    Make this executable
    chmod +x /usr/sbin/usbip_start.sh
    Create stop script
    nano /usr/sbin/usbip_stop.sh
    #!/bin/bash
    /usr/sbin/usbip detach --port=$(/usr/sbin/usbip port | grep '' | sed -E 's/^Port ([0-9][0-9]).*/\1/')
    /usr/sbin/usbip detach --port=$(/usr/sbin/usbip port | grep '' | sed -E 's/^Port ([0-9][0-9]).*/\1/')
    Make this executable
    chmod +x /usr/sbin/usbip_stop.sh
    Create service
    nano /lib/systemd/system/usbip.service
    [Unit]
    Description=usbip client
    After=network.target
    [Service]
    Type=oneshot
    RemainAfterExit=yes
    ExecStartPost=/bin/bash -c '/usr/sbin/usbip_start.sh'
    ExecStop=/bin/bash -c '/usr/sbin/usbip_stop.sh'
    [Install]
    WantedBy=multi-user.target
    systemctl --system daemon-reload
    systemctl enable usbip.service
    systemctl start usbip.service
    Check USB device is attached
    usbip port
    lsusb

    • @peterkleingunnewiek5068
      @peterkleingunnewiek5068 Год назад

      thanks David for de Great tutorial.
      How can I add the USB client to supervised homeassistant?
      So I can add zwavesticks, memory sticks, RFX com usb devices to my virtual homeassistant machine

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  Год назад

      @@peterkleingunnewiek5068 The supervised install uses Debian so you can add the client software similar to what was done in the video. After you attach a USB device it should then be useable

    • @peterkleingunnewiek5068
      @peterkleingunnewiek5068 Год назад

      @@TechTutorialsDavidMcKone Thanks for you Help, when type "apt install usbip hwdata usbutils " for installing client I get in Homeassistant web terminal "zsh: command not found: apt" or do I have to login into de supervisor docker container and must I then install portainer to do this or is the a more simple way to do that? I am using a vmware ova with supervisor-core and host installed. The Hacs installation did work from within this terminal.

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  Год назад

      @@peterkleingunnewiek5068 You need to be logged into the Debian operating system
      Once you add the USB devices there, Home Assistant should be able to detect them like any other USB device

    • @gnulinux-mj
      @gnulinux-mj Год назад

      BigTHX for Information. Very good guidance !!!👌

  • @davidbarker-tf2vo
    @davidbarker-tf2vo Год назад +1

    I needed a long USB cable for my project and I found it here. Arduino Mega Raspberry Pi Ubuntu. Thank you David.

  • @vikasgeu
    @vikasgeu 27 дней назад +1

    can you please tell me how to connect the devices in ARM based server and WSL as a client.

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  27 дней назад

      Unfortunately I don't use Windows or WSL so I don't know
      I suggest searching Google as I tried myself but I don't know if what I found would be relevant
      E.g. I came across this
      github.com/vadimgrn/usbip-win2

  • @streamx2
    @streamx2 2 года назад +1

    I want to share a usb containing some pictures, where would i access those pictures from on the clinet machine ( ubuntu)?

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  2 года назад

      As long as the USB flash drive shows up on the client you should be able to mount it
      You can check if it's detected by Linux by running the following command from a terminal session
      lsusb

  • @elwinbeekman8531
    @elwinbeekman8531 Год назад +1

    i have 2 usb's with same vendor id, do you have a fix for it ? thanks for the video!

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  Год назад

      I'm assuming you have two copies of the same device?
      So the vendor id AND product id are the same
      Not something I've run into as each device on the Pi is different
      But it would require some way of changing the product id
      I did a search on Google myself and didn't find anything particularly useful

    • @elwinbeekman8531
      @elwinbeekman8531 Год назад

      @@TechTutorialsDavidMcKone Hi, thanks for you respone. nah 1 for the evohome ramses, the other is for DSMR (Dutch energy p1 monitor) but same vendor and id. but I did find a workaround. hope it will work.

    • @beadon1
      @beadon1 Год назад

      @@elwinbeekman8531 many time it's possible to flash a new serial number to a USB device like this. However, your mileage may vary ..

  • @davidk.3450
    @davidk.3450 9 месяцев назад +1

    What would be the minimum hardware (server) that one could imagine to transport exactly 1x USB into the network? Because I only need computing power on the client. In an ideal World even with POE ;)

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  9 месяцев назад

      Not sure what else there is other than a Raspberry Pi or similar as you need something to run Linux
      But you can get a POE HAT for a Pi if it helps

    • @davidk.3450
      @davidk.3450 6 месяцев назад

      @@TechTutorialsDavidMcKone For Sure I allready have such. But my PI3 (Pi1+2 do not have PoE Headders) is ideling with 3-5% CPU load for this task. On the other hand the FAN for cooling PoE is runng most of the time. (Btw. PoE for Pi5 is a technical desaster as known).
      So the intention was to hear about something that I had not on my screen. ;)

  • @absak
    @absak Год назад +1

    hey, i am running this in a proxmox LXC container but i cannot get it to make these command work :
    modprobe vhci-hcd
    echo 'vhci-hcd' >> /etc/modules
    i'm guessing these need to be runned at the host shell right ?
    because when i try to run them in the container it says :
    modprobe: FATAL: Module vhci-hcd not found in directory /lib/modules/5.15.102-1-pve
    and when i try to start the service none the less it says Job for usbip.service failed because the control process exited with error code.
    and the error code is
    Mar 26 19:43:39 octoprint-debian systemd[1]: Starting usbip client...
    Mar 26 19:43:39 octoprint-debian bash[15069]: usbip: error: import device
    Mar 26 19:43:39 octoprint-debian bash[15074]: usbip: error: import device
    Mar 26 19:43:39 octoprint-debian systemd[1]: usbip.service: Control process exited, code=exited, status=1/FAILURE
    Mar 26 19:43:39 octoprint-debian systemd[1]: usbip.service: Failed with result 'exit-code'.
    Mar 26 19:43:39 octoprint-debian systemd[1]: Failed to start usbip client.

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  Год назад

      Containers and VMs for that matter are limited in what they can do in all sorts of ways
      If you want to share hardware for instance you have to add it at the host level and then make it available to a container

    • @absak
      @absak Год назад

      @@TechTutorialsDavidMcKoneoh I see, I've been trying to get it to work all day, I'll have a try with that approach when I'll have time, otherwise I'll just use a lan USB extender, but I'd like to get it to work myself...
      And thanks for the quick update !

  • @bahadirm
    @bahadirm Год назад +1

    How do I share USB Devices between Windows systems over IP?
    Currently I'm using RDP+RemoteFX, but the USB device will obviously be disconnected if I disconnect from the RDP session.

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  Год назад +1

      Other than Windows projects that were abandoned a long time ago and so probably unsafe, I only came across commercial options for Windows clients like Flexihub
      Another option I suppose might be Windows Subsystem for Linux
      But that's why the video only covers Linux

    • @eadweard.
      @eadweard. 11 месяцев назад

      There's dorssel/usbipd-win

  • @beadon1
    @beadon1 Год назад +1

    Very useful for connecting USB devices on one machine from another. However, this solution is a little finnicky when the USB devices suddenly disconnect. (someone unplugs from the other side). Or, if the USB device operates in 2 different modes -- as often occurs with embedded systems which is seen by the linux system as a new USB device entirely. Devices like TI , or Nordic chipsets flip between "normal" (debug) and "device firmware update" mode.

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  Год назад

      Yeah, I find it works great for single use over distance, but as you say an interruption breaks things and requires manual intervention
      The code for this was written a long long time ago but it still works and it does the job
      I've been finding it very useful for a VM as it allows me to migrate it between nodes during patching without any downtime

    • @beadon1
      @beadon1 Год назад

      @@TechTutorialsDavidMcKone - If USBIP supported sending an entire "hub" to a remote machine, then unplug/replug and devices switching behaviors while still connected should be a seamless experience. Do you know of a way to export 1 whole hub (and all peripherals then would be shared automatically )

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  Год назад

      @@beadon1Nothing I've really looked into. I just wanted to separate USB devices from Proxmox VE and so USB over IP setup has been working fine

  • @nxtphone4696
    @nxtphone4696 Год назад +1

    thank you for the tutorial. i installed usbip but wasn't able to load the modules. getting "modprobe:FATAL Module usbip_host not found in directory /lib/modules/6.1.19-v8+.
    however the modules are located in /lib/modules/6.1.19-v8+/kernel/drivers/usb/usbip/ compressed as *.ko.xz

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  Год назад +1

      Are you logged in as root or are you using sudo to execute commands?
      And is the Ubuntu OS up to date
      Because it worked fine for me on the latest version while logged in as root

    • @nxtphone4696
      @nxtphone4696 Год назад +1

      @@TechTutorialsDavidMcKone thanks for your suggestions. my raspberry just needed a reboot for some reason but ok. setting up the host and binding my usb-sata docking station worked well just with sudo. not sure the windows client connected succesfully to the adapter but i think it did. unfortunately no HDD drives showed up though.

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  Год назад

      @@nxtphone4696 Good to know things worked
      I haven't tried hard drives, more flash drives as well as USB Z-Wave and Zigbee controllers for Home Assistant

  • @E3SniperspreeE3
    @E3SniperspreeE3 2 года назад +1

    I tried to send a usb3.0 capture card over ip. And I could not get it to work. No card worked. Do you think it could be a driver issue? All other usb devices worked.

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  2 года назад

      Unfortunately I don't have one to test myself but it could be a driver problem

    • @E3SniperspreeE3
      @E3SniperspreeE3 2 года назад

      @@TechTutorialsDavidMcKone Would you consider adding It to the list of video ideas?
      I have tried an elgato, but that is very windows dependent.
      The one I recommend is the Evga XLR lite. It has linux support. Impressive specs for $50 with passthrough. This will work wonderfully for sending video over the network to a streaming pc/server. Ndi is too much cpu for older machines.

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  2 года назад

      Does it work if you plug it directly into the computer rather than connecting over the network?

    • @E3SniperspreeE3
      @E3SniperspreeE3 2 года назад

      @@TechTutorialsDavidMcKone yes. And with an over a 30ft usb extender (active). The ability for other computers to pick up the signal is lost with the direct plug in approach.

  • @melissa6793
    @melissa6793 Год назад +2

    it would be very helpful to put the commands you copy and paste in the description.
    I tried it but keep getting tcp connect errors.
    usbip: error: tcp connect
    Both devices, the Pi and the VM are are on the same subnet

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  Год назад

      Check the pinned comment as that contains the details
      The description doesn't accept some characters

  • @cdxer
    @cdxer 7 месяцев назад +2

    this video needs an update as "apt install usbip" won't work anymore. the package is not found

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  7 месяцев назад

      What OS are you using as it still works for Debian 12?

    • @EdwinFairchild
      @EdwinFairchild 2 месяца назад

      @@TechTutorialsDavidMcKone yeah im on ubuntu latest and doesnt work , neither does ubuntu 22 , however it seems to already be on the machine from the start

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  2 месяца назад +1

      ​@@EdwinFairchild It looks like the package has changed, at least for Ubuntu; linux-tools-generic
      It's still the same for Debian 12, so presumably Canonical made a change
      Unfortunately I don't use Ubuntu anymore so I'm not sure if the package will require different commands on Ubuntu

    • @EdwinFairchild
      @EdwinFairchild 2 месяца назад

      @@TechTutorialsDavidMcKone thanks I got it all working, it amazes me how easy and powerful this is. I am making a Hub of stm32 dev boards to all be remotely programmed and debugged on my desktop

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  2 месяца назад

      @@EdwinFairchild Good to know it's working
      It is very useful, but I hadn't considered stm32

  • @xgrapher
    @xgrapher 11 месяцев назад +2

    how to share over the internet, i can't find a single video, all are for local networks

    • @TechTutorialsDavidMcKone
      @TechTutorialsDavidMcKone  11 месяцев назад +1

      It's usually not a good idea to expose things directly to the Internet
      If you need to access something over the Internet, the better security practice is to setup a VPN tunnel and access any devices through that
      Another concern though might be the extra delay due to the distance apart

    • @xgrapher
      @xgrapher 11 месяцев назад

      @@TechTutorialsDavidMcKone I want to expose, don't worry about it, do you know how to do it, not by VPN or tunnel, then I can simply use TeamViewer. I want USB access over the internet period

  • @davidbarker-tf2vo
    @davidbarker-tf2vo Год назад +1

    Thanks!