# usbip make its job: and udev?

## hujuice

Hello everybody.

I'm excited  :Cool:  (and at the same time I'm feeling uncultured  :Embarassed:  ) playing with usbip.

I felt this application very interesting and I'm glad to share my story.

I need also some help.  :Rolling Eyes: 

usbip makes the interesting job to share a USB device over the network.

For instance, you can "connect" a remote webcam to a local client.

My attempt was successful, but I need some help managing udev.

Take this post as an unfinished 'howto' and, please, help me (us) to perform the last task.

Here begins the good part.

I tried to share a USB HDD between two 3.0.6 kernels.

Let's call server the host where the USB device is attached in and client the host where I want to use it.

In the server's kernel, enable the following drivers:

```
Device Drivers  --->

    [*] Staging drivers  --->

        <M>   USB/IP support (EXPERIMENTAL)

        <M>     Host driver
```

In the client's kernel, enable:

```
Device Drivers  --->

    [*] Staging drivers  --->

        <M>   USB/IP support (EXPERIMENTAL)

        <M>     VHCI hcd[/i]
```

Rebuild your kernels as usually.

On both sides, emerge net-misc/usbip

```
# echo "net-misc/usbip" >> /etc/portage/package.accept_keywords

# emerge net-misc/usbip
```

Take your favourite chair on the server side and do the following (as root).

('box' is my server's hostname.)

Load the module:

```
box # modprobe usbip_host
```

Run 'usbipd'.

(It is not installed as service, just a daemon hanging in your console. The -D option frees your shell. It will be easy to write an initscript.)

```
box # usbipd -D

usbip err: stub_server.c: 433 (do_standalone_mode) open usb.ids                                                                                

listen at [0.0.0.0]:3240

usbipd start (usbip 0.1.7 ($Id: stub_server.c 42 2007-09-07 12:07:51Z hirofuchi $))
```

(The error message did not avoid the following, for me.)

Run the 'bind_driver' tools:

```
box # bind_driver --list

List USB devices

 - busid 1-1 (046d:0805)

         1-1:1.0 -> uvcvideo

         1-1:1.1 -> uvcvideo

         1-1:1.2 -> snd-usb-audio

         1-1:1.3 -> snd-usb-audio

 - busid 1-4 (15a4:9016)

         1-4:1.0 -> none

         1-4:1.1 -> none

 - busid 2-2 (1058:0740)

         2-2:1.0 -> none

 - busid 4-1 (12d1:1003)

         4-1:1.0 -> option

         4-1:1.1 -> option

         4-1:1.2 -> usb-storage

 - busid 4-3 (046d:c31c)

         4-3:1.0 -> usbhid

         4-3:1.1 -> usbhid

 - busid 4-6 (046d:0a12)

         4-6:1.0 -> snd-usb-audio

         4-6:1.1 -> snd-usb-audio

         4-6:1.2 -> snd-usb-audio

         4-6:1.3 -> usbhid

 - busid 3-3 (046d:c05a)

         3-3:1.0 -> usbhid

```

Compare this list to 'lsusb' if you want:

```
box ~ # lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 001 Device 002: ID 046d:0805 Logitech, Inc. Webcam C300

Bus 001 Device 004: ID 15a4:9016 Afatech Technologies, Inc. AF9015 DVB-T USB2.0 stick

Bus 002 Device 003: ID 1058:0740 Western Digital Technologies, Inc. 

Bus 004 Device 002: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem / E230/E270 HSDPA/HSUPA Modem

Bus 004 Device 003: ID 046d:c31c Logitech, Inc. Keyboard K120 for Business

Bus 004 Device 004: ID 046d:0a12 Logitech, Inc. 

Bus 003 Device 002: ID 046d:c05a Logitech, Inc. Optical Mouse M90
```

(Your lists will be different, obviously.)

Choose a device to share. For me, it was the 2-2:

```
box # bind_driver --usbip 2-2

** (process:12762): DEBUG:  2-2:1.0     -> usb-storage 

** (process:12762): DEBUG: unbinding interface

** (process:12762): DEBUG: write "add 2-2" to /sys/bus/usb/drivers/usbip/match_busid

** Message: bind 2-2 to usbip, complete!
```

Now go to the client side chair (ssh from the same favourite) and do the following (as root).

('lap' is my client's hostname.)

Load the module:

```
lap # modprobe vhci_hcd
```

Scan the server availability:

```
lap # usbip --list box

usbip err: vhci_attach.c: 586 (main        ) open usb.ids

- box

     2-2: unknown vendor : unknown product (1058:0740)

        : /sys/devices/pci0000:00/0000:00:04.1/usb2/2-2

        : (Defined at Interface level) (00/00/00)

        :  0 - unknown class / unknown subclass / unknown protocol (08/06/50)
```

Attach the device:

```
lap # usbip --attach box 2-2

usbip err: vhci_attach.c: 586 (main        ) open usb.ids

8 ports available

port 0 attached
```

(An error message again, for me.)

Check the mentioned 'port 0:

```
lap # usbip --port

usbip err: vhci_attach.c: 586 (main        ) open usb.ids

8 ports available

Port 00: <Port in Use> at High Speed(480Mbps)

       unknown vendor : unknown product (1058:0740)

       9-1 -> usbip://box:3240/2-2  (remote devid 00020003 (bus/dev 002/003))

       9-1:1.0 used by usb-storage      

           /sys/devices/platform/vhci_hcd/usb9/9-1/9-1:1.0/host10/scsi_host/host10/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>
```

Take a look to the new USB device:

```
lap # lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 002 Device 002: ID 05c8:010f Cheng Uei Precision Industry Co., Ltd (Foxlink) 

Bus 007 Device 002: ID 03f0:171d Hewlett-Packard Wireless (Bluetooth + WLAN) Interface [Integrated Module]

Bus 009 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 009 Device 013: ID 1058:0740 Western Digital Technologies, Inc.
```

The 'ID 1058:0740 Western Digital Technologies, Inc.' device is available on the client side.

Here ends the good part.

And here is my ignorance and my frustration, because I'm unable to write rules to make udev prepare the corresponding device.

No hotplug, and the 'ls /dev/sd*' command didn't give anything new for me.

How to make the remote USB device really usable?

How to make this half 'howto' a full 'howto'?

Regards,

HUjuice

----------

## zwheel

I hope to get around to trying this soon.  It's too bad that nobody has replied to finish this yet, maybe I'll get it figured out and finish it myself.

Besides making this all happen automatically with init scripts, udev rules, etc... I am wondering... is it possible for the shared device to be a hub?  Could I just plug a hub into the server, designate that hub as 'remote' and anything I plug into it shows up at the client instead of 'locally' at the server?  

That's what I want usb over ip for.  I want to make an X-terminal with usb ports and when you use the usb ports the devices are seen by the remote machine.  I want it to feel just like everything is being done locally even though it isn't.

----------

