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

3 Installing And Using USB/IP On The Client


First we must install usbip on the client. The steps are the same as on the server:

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 vhci-hcd kernel module:

modprobe vhci-hcd

To check if it really got loaded, run:

lsmod | grep vhci_hcd

The output should be similar to this one:

client1:~# lsmod | grep vhci_hcd
vhci_hcd               15844  0
usbip_common_mod       11332  1 vhci_hcd
usbcore               118160  2 vhci_hcd

To make sure that the module gets loaded automatically whenever you boot the system, you can add it to /etc/modules:

vi /etc/modules


Now connect to the usbip server and get a list of available USB devices:

usbip -l

( is the IP address of the usbip server.)

You should find the SanDisk USB flash drive in the output (BUSID 4-5):

client1:~# usbip -l
     4-5: SanDisk Corp. : Cruzer Micro 256/512MB Flash Drive (0781:5151)
        : /sys/devices/pci0000:00/0000:00:04.1/usb4/4-5
        : (Defined at Interface level) (00/00/00)
        :  0 - Mass Storage / SCSI / Bulk (Zip) (08/06/50)


To attach that device to the client, run:

usbip -a 4-5

client1:~# usbip -a 4-5
8 ports available

port 0 attached

Now run...


... and you should find the remote USB device in the output on the client:

client1:~# lsusb
Bus 001 Device 004: ID 0781:5151 SanDisk Corp. Cruzer Micro 256/512MB Flash Drive
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

You can now use the remote USB device as if it was a local USB device (e.g. mount it, format it, write to it, read form it, etc.).


4 Detaching A Remote USB Device

A remote USB device can be detached as follows:



usbip --port

... to find out the port that the remote USB device uses on the client - in this case it's port 00:

client1:~# usbip --port
8 ports available

Port 00: <Port in Use> at High Speed(480Mbps)
       SanDisk Corp. : Cruzer Micro 256/512MB Flash Drive (0781:5151)
       1-1 -> usbip://  (remote devid 00040002 (bus/dev 004/002))
       1-1:1.0 used by usb-storage
Port 01: <Port Available>
Port 02: <Port Available>
Port 03: <Port Available>
Port 04: <Port Available>
Port 05: <Port Available>
Port 06: <Port Available>
Port 07: <Port Available>

We need the port number to detach the device:

usbip -d 00

client1:~# usbip -d 00
8 ports available

port 0 detached

On the server, we use the BUSID (4-5) to bind the USB device to the local system (the --other switch binds the device to the local system so that it is not available over the network anymore):


usbip_bind_driver --other 4-5

server1:~# usbip_bind_driver --other 4-5
** (process:7333): DEBUG: write "del 4-5" to /sys/bus/usb/drivers/usbip/match_busid
** Message: bind 4-5 to other drivers than usbip, complete!

Now go back to the client and check if the remote USB device is still available:



If all goes well, it shouldn't be listed anymore:

client1:~# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


Falko Timme

About Falko Timme

Falko Timme is an experienced Linux administrator and founder of Timme Hosting, a leading nginx business hosting company in Germany. He is one of the most active authors on HowtoForge since 2005 and one of the core developers of ISPConfig since 2000. He has also contributed to the O'Reilly book "Linux System Administration".

Share this page:

Suggested articles

2 Comment(s)

Add comment


By: John Zbesko

Good article about a new feature (to me, anyway) in linux. Is this capability at the heart of the USB device pass-through used in virtual machines, such as Virtualbox?


No, its not. It is completely unrelated, though it might serve the same goal, even more.

 Though, after some testing, USB/IP is still not really reliable because it does not try to reconnect in case of temporary network outage. Maybe that's just a bug.

 On the other side, its kernel part has been integrated early this year in the official linux-staging kernel branch, and its userland is being shipped in most mainstream GNU/Linux distributions already.