usbip的目的是为了开发一个在局域网内共享的USB设备,也就是说你可以直接访问局域网内其他计算机的USB设备。在网上看到一篇如何安装usbip的文章,不过是英文,先转载保存,有时间再翻译下。

  有关它的详细情况可参考其官方网站:http://usbip.sourceforge.net/

  转载地址:http://www.howtoforge.com/how-to-set-up-a-usb-over-ip-server-and-client-with-ubuntu-10.04

  

This tutorial shows how to set up a USB-over-IP server with Ubuntu 10.04 as well as a USB-over-IP client (also running Ubuntu 10.04). 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 Ubuntu 10.04 (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 server1.example.com with the IP address 192.168.0.100 and the client client1.example.com with the IP address192.168.0.101, both running Ubuntu 10.04. These settings might differ for you, so you have to replace them where appropriate.

2 Installing And Using USB/IP On The Server

server1:

We can install usbip as follows:

aptitude install usbip

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:

root@server1:~# lsmod | grep usbip
usbip                  15124  0
usbip_common_mod       13605  1 usbip
root@server1:~#

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

vi /etc/modules

[...]
usbip
usbip_common_mod

Now we can start the usbip daemon:

usbipd -D

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

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

lsusb

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:

root@server1:~# lsusb
Bus 001 Device 002: ID 0781:5151 SanDisk Corp. Cruzer Micro Flash Drive
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
root@server1:~#

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:

root@server1:~# usbip_bind_driver --list
List USB devices
 - busid 1-1 (0781:5151)
         1-1:1.0 -> usb-storage

root@server1:~#

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

usbip_bind_driver --usbip 1-1

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

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:

root@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 *:ssh                   *:*                     LISTEN      537/sshd
tcp        0      0 *:3240                  *:*                     LISTEN      762/usbipd
tcp        0     52 server1.example.com:ssh 192.168.0.199:4024      ESTABLISHED 667/0
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      537/sshd
root@server1:~#

3 Installing And Using USB/IP On The Client

client1:

We must install usbip on the client as well:

aptitude install usbip

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:

root@client1:~# lsmod | grep vhci_hcd
vhci_hcd               19800  0
usbip_common_mod       13605  1 vhci_hcd
root@client1:~#

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

vi /etc/modules

[...]
vhci-hcd

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-1):

root@client1:~# usbip -l 192.168.0.100
- 192.168.0.100
     1-1: SanDisk Corp. : Cruzer Micro Flash Drive (0781:5151)
        : /sys/devices/pci0000:00/0000:00:07.2/usb1/1-1
        : (Defined at Interface level) (00/00/00)
        :  0 - Mass Storage / SCSI / Bulk (Zip) (08/06/50)

root@client1:~#

To attach that device to the client, run:

usbip -a 192.168.0.100 1-1

root@client1:~# usbip -a 192.168.0.100 1-1
8 ports available

port 0 attached
root@client1:~#

Now run...

lsusb

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

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

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:

root@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://192.168.0.100:3240/1-1  (remote devid 00010002 (bus/dev 001/002))
       1-1:1.0 used by usb-storage
           /sys/class/bsg/1:0:0:0/device
           /sys/class/scsi_device/1:0:0:0/device
           /sys/class/scsi_disk/1:0:0:0/device
           /sys/class/scsi_host/host1/device
           /sys/class/usb_endpoint/usbdev1.4_ep02/device
           /sys/class/usb_endpoint/usbdev1.4_ep81/device
           /sys/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>
root@client1:~#

We need the port number to detach the device:

usbip -d 00

root@client1:~# usbip -d 00
8 ports available

port 0 detached
root@client1:~#

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

usbip_bind_driver --other 1-1

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

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:

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

5 Links

  • USB/IP Project: http://usbip.sourceforge.net/
  • Ubuntu: http://www.ubuntu.com/

转载于:https://www.cnblogs.com/stevengerrard/archive/2011/10/30/2228979.html

转载---How To Set Up A USB-Over-IP Server And Client With Ubuntu 10.04相关推荐

  1. Ubuntu 16.04 LTS 初体验 (转载)

    一.前言 心血来潮,下载最新的Ubuntu Kylin 16.04尝鲜.但刚装完系统,还是有很多问题需要自己动手解决,这里就是把自己实际遇到的问题总结记录,希望也可以为其他刚接触 Ubuntu 的朋友 ...

  2. USB大容量存储设备该设备无法启动(代码 10)

    在设备管理器中查看有感叹号,出现了"USB大容量存储设备该设备无法启动(代码 10)"的提示 解决方法如下: 1.按下"Win + R"组合键打开运行窗口,输入 ...

  3. Ubuntu 14.04.1 配置 Android 源码开发环境(jdk版本切换)(转载)

    转自:http://www.cnblogs.com/ren-gh/p/4248407.html # Ubuntu 14.04.1 1.更新源: sudo apt-get update 安装vim工具: ...

  4. Ubuntu 16.04 一系列软件安装命令,包括QQ、搜狗、Chrome、vlc、网易云音乐安装方法(转载)...

    转自博客:https://blog.csdn.net/fuchaosz/article/details/51882935 1 简介 Ubuntu 16.04安装完后,还需要做一些配置才能愉快的使用,包 ...

  5. Ubuntu 14.04 安装 USB无线网卡驱动

    近期由于台式机无线上网的需要,买了个TP-LINK TL-WN823N 300M迷你USB无线网卡,但是由于官网只有windows的驱动,在linux下就只能自己丰衣足食了. 我的系统是Ubuntu ...

  6. ubuntu 18.04 usb无线网卡无法使用--ID 0bda:a192 Realtek Semiconductor Corp.

    问题描述:ubuntu 18.04 插上一款Tenda 的usb无线驱动,能找到该usb设备,但是wifi网络不显示 原因:应该是驱动的问题 查看usb设备: lsusb 结果发现是有这个设备的(就下 ...

  7. (已解决) Ubuntu 16.04 下安装和使用 TP-Link 的USB无线网卡

    在 Ubuntu 16.04 下使用 TP-Link USB无线网卡的通用方法 第一步: 查看 TP-link 网卡具体型号 未插无线网卡时, 终端里输入 lsusb 插上USB无线网卡, 终端里再次 ...

  8. 【转载贴】Ubuntu 20.04下使用微信和TIM和QQ以及字体乱码(小黑块)/太小的一条龙解决方案

    [转载贴]Ubuntu 20.04下使用微信和TIM和QQ以及字体乱码(小黑块)/太小的一条龙解决方案 下载:Ubuntu 20.04 下微信QQTIM的优雅使用 乱码解决:Ubuntu20.04 w ...

  9. 华硕主板运行 linux花屏,启动Ubuntu 16.04 Live DVD/USB碰到花屏的解决方案

    以下在 Virtualbox 启动 Ubuntu 16.04 Live DVD/USB 碰到花屏为案例 实验解决方案的报告 实体机基本上适用,但是部份可能需要微调 1. 在 Virtualbox Gu ...

最新文章

  1. 简单介绍nginx 变量使用
  2. 分布式系统的面试题14
  3. h.264的POC计算
  4. linux docker 报错 Failed to get D-Bus connection: Operation not permitted
  5. 什么是万词霸屏?做万词霸屏有效果么?
  6. 修改数据无法提交_学习篇管家婆物联通功能讲解--|修改客户
  7. 浅谈ICA算法的概念、本质和流程
  8. java stream 多次读取_多次从具有大量数据的Java InputStream中读取
  9. 提升面对电脑的工作效率
  10. 【终结版】C#常用函数和方法集汇总
  11. ref的mysql_ref:Mysql授权远程登陆
  12. ORACLE查询表最近更改的数据
  13. ltp︱基于ltp的无监督信息抽取模块
  14. 计算机视觉方面的三大国际会议是ICCV, CVPR和ECCV,我统称之为ICE。
  15. win10运行命令大全
  16. 齐次线性方程组与非齐次线性方程组的区别
  17. 硬件工程师的你也不想一辈子画图、调板子吧!!!
  18. vue项目引入高德地图
  19. pc端支付宝支付和微信支付(vue)
  20. leetcode 剑指 Offer 46. 把数字翻译成字符串

热门文章

  1. [MATLAB App Desinger] 树(Tree)与表(UITable)的结合应用
  2. 对抗自编码器(AAE)
  3. linux 6不能自动挂载u盘,Linux CentOS 6.7 挂载U盘
  4. 熟悉 Linux 命令运维工程师必备
  5. Web静态页面:华为商城主页
  6. 怎么关闭win10搜索框网页搜索功能
  7. ReactNative_Simulator com+r不能刷新模拟器
  8. cad对计算机的配置要求高吗,AutoCAD2018对电脑配置要求 需要什么配置的电脑
  9. 支付宝沙箱支付AlipayEasy
  10. html chat柱状图模板,chart.js柱状图