USB/IP-Ubuntu 14.04服务端操作手册

1. 安装USB/IP

1.1. 查看内核是否打开了USBIP的支持

egrep USBIP /boot/config-3.13.0-xx-generic 

CONFIG_USBIP_CORE=m

CONFIG_USBIP_VHCI_HCD=m

CONFIG_USBIP_HOST=m

# CONFIG_USBIP_DEBUG is not set

1.2. 编译安装

创建脚本make-usbip-userspace.sh

#!/bin/bash

 

# Requires a linux kernel higher than 3.2.0-22.25

 

# Determine the current kernel version and relevant directories

kernelver=`uname -r | cut -d '-' -f 1`

builddir=~/build/

kernelloc=drivers/staging/usbip/userspace/

 

# Setting up the build directory

if [ -d ${builddir} ]

then

        echo "E: Directory ${buiddir} would be used for building but already exists."

        echo "   Please remove this directory in order to build cleanly."

        exit 1

fi

 

mkdir -p ${builddir}

 

# Getting the source code into the build directory

sudo apt-get install linux-source-${kernelver}

tar -x -f /usr/src/linux-source-${kernelver}.tar.bz2 -C ${builddir}

cd ${builddir}/linux-source-${kernelver}

 

# Install required packages for building

sudo apt-get install sysfsutils libwrap0-dev gcc libglib2.0-dev libtool automake autoconf pkg-config libsysfs-dev

 

# Do the actual build

cd ${kernelloc}

./autogen.sh

./configure --with-usbids-dir=/usr/share/misc/

sudo make install

 

# Create a soft-link so the client space tools find the libraries

sudo ln -s /usr/local/lib/libusbip.so.0 /usr/lib/libusbip.so.0

执行./make-usbip-userspace.sh

引用:

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/900384

#10

https://launchpadlibrarian.net/106481975/make-usbip-userspace.sh

1.3. 加载USBIP相应的模块

modprobe usbip_host 

modprobe usbip_core

modprobe vhci_hcd

可以将模块加入/etc/modules,系统自启动加载

lsmod | grep usbip

usbip_host             23867  0 

usbip_core             32112  2 usbip_host,vhci_hcd

1.4. 运行USBIP后台进程

运行usbipd -D

2. USB/IP设备管理

2.1. 查看本机插上的设备的总线IDbus id

root@inspiron:~# usbip list -l

Local USB devices

=================

 - busid 1-1 (8087:0024)

   Intel Corp. : Integrated Rate Matching Hub (8087:0024)

         1-1:1.0 -> hub

 

 - busid 1-1.3 (0bda:0129)

   Realtek Semiconductor Corp. : RTS5129 Card Reader Controller (0bda:0129)

         1-1.3:1.0 -> rts5139

 

 - busid 1-1.5 (0c45:648d)

   Microdia : unknown product (0c45:648d)

         1-1.5:1.0 -> uvcvideo

         1-1.5:1.1 -> uvcvideo

 

 - busid 2-1 (8087:0024)

   Intel Corp. : Integrated Rate Matching Hub (8087:0024)

         2-1:1.0 -> hub

 

 - busid 3-2 (0951:1643)

   Kingston Technology : DataTraveler G3 (0951:1643)

         3-2:1.0 -> usb-storage

 

 - busid 3-3 (046d:c52b)

   Logitech, Inc. : Unifying Receiver (046d:c52b)

         3-3:1.0 -> usbhid

         3-3:1.1 -> usbhid

         3-3:1.2 -> usbhid

看到标识为蓝色的即为USB设备

2.2. 根据查到的总线ID 绑定在usbip-host

root@inspiron:~# usbip bind -b 3-2

bind device on busid 3-2: complete

2.3. 确认设备已经绑定到usbip-host

root@inspiron:~# usbip list -r 127.0.0.1

Exportable USB devices

======================

 - 172.16.4.1

        3-2: Kingston Technology : DataTraveler G3 (0951:1643)

           : /sys/devices/pci0000:00/0000:00:14.0/usb3/3-2

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

           :  0 - Mass Storage / SCSI / Bulk-Only (08/06/50)

 

root@inspiron:~# usbip list -l

Local USB devices

=================

 - busid 1-1 (8087:0024)

   Intel Corp. : Integrated Rate Matching Hub (8087:0024)

         1-1:1.0 -> hub

 

 - busid 1-1.3 (0bda:0129)

   Realtek Semiconductor Corp. : RTS5129 Card Reader Controller (0bda:0129)

         1-1.3:1.0 -> rts5139

 

 - busid 1-1.5 (0c45:648d)

   Microdia : unknown product (0c45:648d)

         1-1.5:1.0 -> uvcvideo

         1-1.5:1.1 -> uvcvideo

 

 - busid 2-1 (8087:0024)

   Intel Corp. : Integrated Rate Matching Hub (8087:0024)

         2-1:1.0 -> hub

 

 - busid 3-2 (0951:1643)

   Kingston Technology : DataTraveler G3 (0951:1643)

         3-2:1.0 -> usbip-host

 

 - busid 3-3 (046d:c52b)

   Logitech, Inc. : Unifying Receiver (046d:c52b)

         3-3:1.0 -> usbhid

         3-3:1.1 -> usbhid

         3-3:1.2 -> usbhid

标识为蓝色的由usb-storage->usbip-host

这时候Ubuntu客户端或者Windows客户端可以连接使用

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值