And the icing on this cake is that to share a USB through Ethernet you don’t really need to permanently turn your Raspberry Pi into a USB server. You can share dongle keys, webcams, printer units, and other peripherals plugged into USB ports of all computers with installed FlexiHub, including your Android tablet, and never have any trouble with cross-platform connectivity. From a Windows machine, you can even share a COM-based peripheral. How awesome is that? And, for added convenience, you’ll get an opportunity to enjoy wireless connectivity accessing shared USB devices via Wi-Fi. So long to all those CAT5e cables laying around the office.
In principle, this method is similar to the one we've just described, but through the agency of a different USB to Ethernet extension app. And given that this time we’ll be using an open-source solution that's still in development, the set-up process requirements are there for a decent level of technical competence to perform so if you don’t have any, don't be surprised if it won’t work on the first go.
Here are some more important points you need to consider before opting for this method:
Alternatively, you can create a systemd service:
with the following definition (don’t forget to change the N for an actual USB ID number of your device):
Description=usbip host daemon
ExecStartPost=/bin/sh -c "/usr/sbin/usbip bind --$(/usr/sbin/usbip list -p -l | grep '#usbid=N#' | cut '-d#' -f1)"
ExecStop=/bin/sh -c "/usr/sbin/usbip unbind --$(/usr/sbin/usbip list -p -l | grep '#usbid=N#' | cut '-d#' -f1); killall usbipd"
And then you'll need to run these commands to start that service:
sudo systemctl --system daemon-reload
sudo systemctl enable usbipd.service
sudo systemctl start usbipd.service
Ok, now let's set up a client:
Note: The app does have a client for Windows, but it’s a flimsy beta version with no signed drivers or any support for Windows 10, thus not really worth mentioning.
1. To install the same app for sharing USB over IP in Ubuntu, execute these commands:
apt-get install linux-tools-generic -y
2. Enable the required module:
echo 'vhci-hcd' >> /etc/modules
Now, to connect the shared device to this machine, run the command:
sudo usbip attach -r 0.0.0.0
(type the actual IP address of your Raspberry Pi instead of 0.0.0.0)
Or you can create a systemd service:
With the definition (replace N with an actual USB ID number of your device and 0.0.0.0 with your Raspberry’s IP address):
[Unit] Description=usbip client After=network.target [Service] Type=oneshot RemainAfterExit=yes ExecStart=/bin/sh -c "/usr/lib/linux-tools/$(uname -r)/usbip attach -r 0.0.0.0 -b $(/usr/lib/linux-tools/$(uname -r)/usbip list -r 0.0.0.0 | grep 'N' | cut -d: -f1)" ExecStop=/bin/sh -c "/usr/lib/linux-tools/$(uname -r)/usbip detach --port=$(/usr/lib/linux-tools/$(uname -r)/usbip port | grep '<Port in Use>' | sed -E 's/^Port ([0-9][0-9]).*/\1/')" [Install] WantedBy=multi-user.target
Save, and then run these commands to start the service:
sudo systemctl --system daemon-reload
sudo systemctl enable usbip.service
sudo systemctl start usbip.service
After that, you should be able to access the shared device remotely. If not, try all the steps again from the very beginning.
Important! If you unplug a USB device from the Raspberry Pi while it’s shared by this method it may result in permanent data loss. Turn off your Raspberry first (after it’s off, you can also disconnect its AC adapter for extra precautions).
Building a wireless USB over IP hub with a Raspberry Pi is a relatively simple exercise if you have the following two components.
VirtualHere enables the sharing of network-attached USB devices. It’s a solution that lets you connect remote USB devices and use them as if they were directly attached to your local machine. A VirtualHere server allows you to remotely access USB devices like scanners, printers, and webcams from any location on your network.
You can create a hub to support USB over IP using Raspberry Pi with the following steps.
$ wget https://www.virtualhere.com/sites/default/files/usbserver/vhusbdarm
$ chmod +x vhusbdarm
$ sudo ./vhusbdarm -b
See the available options by executing this command:
$ ./vhusbdarm -h
Any type of USB device can be connected over the network with this method. The number of open ports presents the only limitation on the number of devices you can connect. You can also add a physical USB hub to provide more USB ports and enable you to connect additional devices.
The decision of which method to adopt from the ones described in this article is entirely yours. However, it might be wiser to opt for a user-friendly tool with a track record of effectiveness rather than risking potential downtime, which could lead to considerable stress, time loss, and financial expenses. Choose what works best for you.