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
创建脚本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
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
运行usbipd -D
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设备
root@inspiron:~# usbip bind -b 3-2
bind device on busid 3-2: complete
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客户端可以连接使用