How To Set Up A USB-Over-IP Server And Client With Debian Lenny

Version 1.0
Author: Falko Timme
Follow me on Twitter

This tutorial shows how to set up a USB-over-IP server with Debian Lenny as well as a USB-over-IP client (also running Debian Lenny). The USB/IP Project aims to develop a general USB device sharing system over IP network. To share USB devices between computers with their full functionality, USB/IP encapsulates "USB I/O messages" into TCP/IP payloads and transmits them between computers. USB-over-IP can be useful for virtual machines, for example, that don't have access to the host system's hardware - USB-over-IP allows virtual machines to use remote USB devices.

I do not issue any guarantee that this will work for you!


1 Preliminary Note

This tutorial is based on AliRezaTaleghani's tutorial How To Modify Your Gnu/Linux Box To Serve As A USB Over IP Server, but I've adjusted it for Debian Lenny (server and client). If you want to use a Windows client, please take a look at AliRezaTaleghani's tutorial - that part is still the same.

In this tutorial I use the server with the IP address and the client with the IP address, both running Debian Lenny. These settings might differ for you, so you have to replace them where appropriate.


2 Installing And Using USB/IP On The Server


There's a usbip package for Debian Squeeze (testing), but not for Lenny. To install the usbip package from Squeeze on Lenny, we modify the following three files (take a look at my tutorial A Short Introduction To Apt-Pinning to understand what I'm doing here):

vi /etc/apt/sources.list

Add the Debian Squeeze (testing) repositories at the end of the file:

## Squeeze / Testing
deb squeeze main
deb-src squeeze main

deb squeeze/updates main
deb-src squeeze/updates main

vi /etc/apt/apt.conf

Put the following line into this file:

APT::Cache-Limit "100000000";

vi /etc/apt/preferences

Make the file look as follows:

Package: *
Pin: release a=stable
Pin-Priority: 700

Package: *
Pin: release a=testing
Pin-Priority: 650

Update the package database...

aptitude update

... and install usbip as follows:

aptitude install usbip usbip-source module-assistant

We need to build the usbip kernel modules for our Debian Lenny kernel, that's why we must install the usbip-source and module-assistant packages as well. We can now build the kernel modules as follows:

m-a prepare

m-a update

m-a a-i usbip-source

Afterwards we load the usbip kernel modules:

modprobe usbip
modprobe usbip_common_mod

To check if they really got loaded, run:

lsmod | grep usbip

The output should be similar to this one:

server1:~# lsmod | grep usbip
usbip                  18660  0
usbip_common_mod       17672  1 usbip

To make sure that both modules get loaded automatically whenever you boot the system, you can add them to /etc/modules:

vi /etc/modules


Now we can start the usbip daemon:

usbipd -D

server1:~# usbipd -D
Bind usbip.ko to a usb device to be exportable!

Now attach a USB device that you want to export to the server - I'm using a SanDisk USB flash drive here.

Execute the command


to find the corresponding Vendor/Device ID which is in the form of:

Bus XXX Device YYY: ID VendorID:DeviceID

The output on my server is as follows:

server1:~# lsusb
Bus 004 Device 002: ID 0781:5151 SanDisk Corp. Cruzer Micro 256/512MB Flash Drive
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 058f:6362 Alcor Micro Corp. Hi-Speed 21-in-1 Flash Card Reader/Writer (Internal/External)
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

The Vendor/Device ID of my SanDisk USB flash drive is 0781:5151.

Now run

usbip_bind_driver --list

The output on my server is as follows:

server1:~# usbip_bind_driver --list
List USB devices
 - busid 3-4 (058f:6362)
         3-4:1.0 -> usb-storage

 - busid 4-5 (0781:5151)
         4-5:1.0 -> usb-storage


As you see, the Vendor/Device ID of my SanDisk USB flash drive (0781:5151) corresponds to the BUSID 4-5. We need this BUSID to attach the USB device to the server:

usbip_bind_driver --usbip 4-5

server1:~# usbip_bind_driver --usbip 4-5
** (process:7290): DEBUG:  4-5:1.0      -> usb-storage
** (process:7290): DEBUG: unbinding interface
** (process:7290): DEBUG: write "add 4-5" to /sys/bus/usb/drivers/usbip/match_busid
** Message: bind 4-5 to usbip, complete!

That's it, we can now use the SanDisk USB flash drive on a remote usbip client.

BTW, if you run...

netstat -tap

... you should see that the usbip daemon is listening on port 3240 so please make sure that this port isn't blocked by your firewall:

server1:~# netstat -tap
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 *:sunrpc                *:*                     LISTEN      2062/portmap
tcp        0      0 *:49008                 *:*                     LISTEN      2073/rpc.statd
tcp        0      0 *:ssh                   *:*                     LISTEN      3244/sshd
tcp        0      0 localhost.localdom:smtp *:*                     LISTEN      2546/exim4
tcp        0    172      ESTABLISHED 3204/0
tcp        0    148      ESTABLISHED 3245/1
tcp6       0      0 [::]:3240               [::]:*                  LISTEN      7254/usbipd
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      3244/sshd

Share this page:

7 Comment(s)

Add comment



Thank you Falko. I needed this. You are the man

From: Medifast

wow, this is a very extensive tutorial, and even can be understood by a techno-bloke like yours truly.  Thank you very much!

From: Anonymous

It seems to not be possible to compile the modules with a newer kernel:

/usr/src/modules/usbip/src/stub_dev.c: In function 'stub_probe': /usr/src/modules/usbip/src/stub_dev.c:392: error: 'struct device' has no member named 'bus_id' make[4]: *** [/usr/src/modules/usbip/src/stub_dev.o] Error 1

Current 'struct device' in linux/device.h hasn't 'bus_id' (at least with kernels newer than 2.6.30).

From: Anonymous

"Current 'struct device' in linux/device.h hasn't 'bus_id' (at least with kernels newer than 2.6.30)"


From: DrLex

The module is included in the kernel tree since 2.6.28. Either use those sources or configure your kernel for it. Chances are that “modprobe usbip” will work right away.

From: Anonymous

It works fine as it is, but for some uses it is preferrable to run over an encryptet connection.
Has anyone had any luck in getting this to work over an ssh tunnel?

on-server# ssh -R 3240:localhost:3240 client-ip
on-client# usbip -l localhost ; # Works ok
on-client# usbip -a localhost x.y ; # Works ok
on-client# usbip -p ; # lists port 00 as "initializing"

Probing and connecting directly works as expected.

From: JAX

I followed the steps till "aptitude update". But i met this kind of error. If someone knows about it. Please help me

invalid record in the preferences file /etc/apt/preferences no package header