How To Set Up A USB-Over-IP Server And Client With Mandriva 2010.0 - Page 2

3 Installing And Using USB/IP On The Client

client1:

First 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:

[[email protected] administrator]# lsmod | grep vhci_hcd
vhci_hcd               22840  0
usbip_common_mod       22168  1 vhci_hcd
usbcore               219188  2 vhci_hcd
[[email protected] administrator]#

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

vi /etc/modprobe.preload

[...]
vhci-hcd

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

urpmi wget flex gcc gcc-c++ libsysfs-devel libglib2.0-devel

cd /tmp
wget http://downloads.sourceforge.net/project/usbip/usbip/0.1.7/usbip-0.1.7.tar.gz?use_mirror=kent
tar xvfz usbip-0.1.7.tar.gz
cd usbip-0.1.7/src/
./autogen.sh
./configure
make
make install

usbip expects the file containing the list of known USB devices (usb.ids) in the directory /usr/share/hwdata, but on Mandriva 2010.0 it's located in /usr/share/usb.ids - therefore we create a symlink:

mkdir /usr/share/hwdata
ln -sf /usr/share/usb.ids /usr/share/hwdata/

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

usbip -l 192.168.0.100

(192.168.0.100 is the IP address of the usbip server.)

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

[[email protected] src]# usbip -l 192.168.0.100
- 192.168.0.100
     1-5: SanDisk Corp. : Cruzer Micro Flash Drive (0781:5151)
        : /sys/devices/pci0000:00/0000:00:02.1/usb1/1-5
        : (Defined at Interface level) (00/00/00)
        :  0 - Mass Storage / SCSI / Bulk (Zip) (08/06/50)

[[email protected] src]#

To attach that device to the client, run:

usbip -a 192.168.0.100 1-5

[[email protected] src]# usbip -a 192.168.0.100 1-5
8 ports available

port 0 attached
[[email protected] src]#

Now run...

lsusb

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

[[email protected] src]# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 023: ID 0781:5151 SanDisk Corp. Cruzer Micro Flash Drive
[[email protected] src]#

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:

client1:

Run...

usbip --port

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

[[email protected] src]# usbip --port
8 ports available

Port 00: <Port in Use> at High Speed(480Mbps)
       SanDisk Corp. : Cruzer Micro Flash Drive (0781:5151)
       1-1 -> usbip://192.168.0.100:3240/1-5  (remote devid 00010003 (bus/dev 001/003))
       1-1:1.0 used by usb-storage
           /sys/devices/platform/vhci_hcd/usb1/1-1/1-1:1.0/host5/target5:0:0/5:0:0:0/block/sdb/device
           /sys/devices/platform/vhci_hcd/usb1/1-1/1-1:1.0/host5/target5:0:0/5:0:0:0/bsg/5:0:0:0/device
           /sys/devices/platform/vhci_hcd/usb1/1-1/1-1:1.0/host5/target5:0:0/5:0:0:0/scsi_device/5:0:0:0/device
           /sys/devices/platform/vhci_hcd/usb1/1-1/1-1:1.0/host5/target5:0:0/5:0:0:0/scsi_disk/5:0:0:0/device
           /sys/devices/platform/vhci_hcd/usb1/1-1/1-1:1.0/host5/target5:0:0/5:0:0:0/scsi_generic/sg2/device
           /sys/devices/platform/vhci_hcd/usb1/1-1/1-1:1.0/host5/scsi_host/host5/device
           /sys/devices/platform/vhci_hcd/usb1/1-1/1-1:1.0/host5/target5:0:0/5:0:0:0/block/sdb/device
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>
[[email protected] src]#

We need the port number to detach the device:

usbip -d 00

[[email protected] src]# usbip -d 00
8 ports available

port 0 detached
[[email protected] src]#

On the server, we use the BUSID (1-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):

server1:

bind_driver --other 1-5

[[email protected] administrator]# bind_driver --other 1-5
** (process:3484): DEBUG: write "del 1-5" to /sys/bus/usb/drivers/usbip/match_busid
** Message: bind 1-5 to other drivers than usbip, complete!
[[email protected] administrator]#

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

client1:

lsusb

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

[[email protected] src]# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[[email protected] src]#

 

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

0 Comment(s)

Add comment