It is a common problem: I have a USB device on a computer out in the shop, and I want to use it from the comfort of my office. What to do? Well, you could remote desktop into the distant machine. But, honestly, I always find any remote desktop more than ssh clunky and somewhat undesirable. Fortunately, Linux can do virtually anything if you only know how to do it. So, this time, I’ll show you how to transport a USB device over your network. Of course, I have a network that reaches out to the shop. It should be a simple matter to tell my desktop machine that one of its USB devices lives across the network. Well, it wasn’t that simple, but it is doable.The ToolsThe whole thing involves a program called usbip. That should be the end of it, but of course, it isn’t. In order for this to work, both machines on the network will need some kernel modules and a daemon on the server: the machine with the USB devices to share.You may be able to install usbip from your package manager. On Ubuntu, it is in the linux-tools-common package, so a simple apt-get might give you everything you need. I wasn’t so lucky.How far away can you mount this USB drive?I use a custom kernel (xanmod), so I had a problem. While I had the kernel modules, I didn’t have the client tools and the ones in the standard repository are tied to your kernel version. Running the stock versions gave me an error message. So I had to find a way to make things myself.Here’s what you need in the way of kernel modules on the server: usbip_core, usbip_host. You also need usbipd (the daemon). On both machines, you need the control program, usbip. On the client machine, you need the vhci_hcd module. If you can get all this working and with compatible versions, you are pretty much home-free.In my case, I had to download my kernel source and find the tools/usb/usbip directory. Normally, you can build everything with the Makefile in tools/, but this seems to be a special case. You run the autogen.sh file to create the build setup. Then do a ./configure and a make. A make install will finish things up. Just be sure that where it installs for you is where you run the tools in the next steps.The Pi ConnectionMany people use a Raspberry Pi as a sort of USB server. In that case, the setup is pretty easy:sudo apt install usbip hwdata usbutilsThat should get you everything you need. For that matter, if you run a pretty stock version of Ubuntu, you might try:sudo apt install linux-tools-generic linux-cloud-tools-genericFor anything else, you’ll need to do some homework.SetupAssuming you have everything ready, you need to do several things. First, you must load the modules on both the server and the client. Then, you need to run the daemon on the server. You can bind one or more USB devices to the server using the command line tool. Notice that the USB device has to be free; once you bind it to the server, you can’t use it directly anymore.You’ll then connect with the client. Again, one client acquires the device, and that’s it. It can’t be shared. Sure, you can release it, and someone else can get it. Or the server can drop it, returning the device for local use. However, while the server has the device, only one client can use that device at any given time.Loading the modules is easy with modprobe, although over the long term, you probably want to add them to /etc/modules-load.d so they will load at boot time. For now, on the server, try:sudo modprobe -a usbip_core usbip_hostOn the client:sudo modprobe -a vhci_hcdYou’ll also have to run usbipd on the server. You can do that in any way you usually run a daemon, including systemd, rc.local, or whatever. For now, just run it as root from the command line.You need to find at least one device to share, so from the server try:sudo usbip list -l # -l for localThis will give you a list of devices. What you want is the “bus id.” Suppose it is 4-3.1. You’ll bind that device to the server:sudo usbpip bind -b 4-3.1Now, from the client, you should be able to see the device:sudo usbip list -r myserver.local # use your server name or IPYou can then attach to it:usbip attach -r myserver.local -b 4-3.1CommandsA good first test is to share a USB drive over the network. There are other ways to do this, but it is easy to see that it works with standard software. Here’s a transcript, assuming root prompts on both server and client, along with all the preliminary setup:server # usbip list -l...- busid 5-2.1.2.3 (0781:5575)SanDisk Corp. : Cruzer Glide (0781:5575)...server # usbip bind -b 5-2.1.2.3client # usbip list -r 192.168.1.2 # or whatever IP/addressExportable USB devices======================- 192.168.1.25-2.1.2.3: SanDisk Corp. : Cruzer Glide (0781:5575): /sys/devices/pci0000:00/0000:00:01.2/0000:01:00.0/0000:02:08.0/0000:08:00.3/usb5/5-2/5-2.1/5-2.1.2/5-2.1.2.3: (Defined at Interface level) (00/00/00)client # ls /dev/sd* # see what hard drives are available before sharing/dev/sda /dev/sda1 /dev/sda2 /dev/sda3client # usbip attach -r 192.168.1.2 -b 5-2.1.2.3client # ls /dev/sd*/dev/sda /dev/sda1 /dev/sda2 /dev/sda3 /dev/sdb /dev/sdb1 /dev/sdb2 /dev/sdb3client # mount /dev/sdb3 /mntclient # ls /mnt... output of ls ...client # umount /mntclient # usbip portImported USB devices====================Port 00: at High Speed(480Mbps)SanDisk Corp. : Cruzer Glide (0781:5575)3-1 -> usbip://192.168.1.2:3240/5-2.1.2.3-> remote bus/dev 005/028client # usbip detach -p 00 # 00 is port number from aboveserver # usbip unbind -b 5-2.1.2.3 # release from server, tooNote that you have to detach by port number, even though everything else takes a bus ID, which is somewhat dynamic across reboots. Also, if the system suspends, you may have to reshare the device.This GUI for usbip has a Hackaday.io page and a project on GitHub.To summarize, you can use variations of the list command to show local or remote devices. If you ask the server to show you remote devices on 127.0.0.1, you can easily see what devices are exported. On the client, the port command shows you what’s connected.On the server, you bind or unbind devices. On the client, you attach and detach.Once the device attaches, it looks like any other USB port on your system. Pretty cool!If the command line isn’t your thing, we noticed a Hackaday.io project aimed at creating a Qt GUI for the client work. It doesn’t seem to be active, but it might be something to try or someplace to start.The Windows ConnectionThere are two clients for using USB devices on Windows. The newer one requires you to be in test signing mode and has several other warnings. It originally forked from an older version that some people prefer and may support the server part, too. I haven’t tried it, so if you want to explore using Windows, you are on your own but do report what you find in the comments.Usually, we want our USB cables shorter, not longer. We wonder if a USB keyboard and monitor with a Pi server could make a good remote terminal.