Purpose
USB/IP enables sharing USB devices over IP by encapsulating USB/IO messages as TCP/IP payloads. This allows USB devices to be accessed across different computers over a network.
Features of USB/IP
USB/IP supports various USB devices and use cases, including:
- Storage Devices: Perform operations like
fdisk,mkfs,mount/umount, file transfers, playing DVD movies, and recording DVD-R media. - Input Devices: Use USB keyboards and mice with Linux consoles or the X Window System.
- Multimedia Devices: Operate USB webcams to capture images and play music via USB speakers.
- Other Devices: Use USB printers, scanners, serial converters, and Ethernet interfaces.
Note
The usbip package is included in linux-tools-common and can be installed without compiling from source.
Installation Steps
1. Using Linux Tools (Recommended)
Install necessary tools and dependencies using the following commands:
$ sudo apt install linux-oem-5.6-tools-common
$ sudo apt install linux-tools-generic
$ sudo apt install linux-cloud-tools-generic
$ sudo apt install hwdata
$ sudo apt install usb.ids
To uninstall these tools:
$ sudo apt-get purge --auto-remove linux-oem-5.6-tools-common
$ sudo apt-get purge --auto-remove linux-tools-generic
$ sudo apt-get purge --auto-remove linux-cloud-tools-generic
2. Installing from Source
After downloading the source code, navigate to the source directory and run:
$ ./autogen.sh
$ ./configure
$ make
$ make install
Post-Installation Paths
- Libraries:
/usr/local/lib - Drivers:
/usr/lib/modules/<kernel-version>/kernel/drivers/usb/usbip - USB/IP library path:
/SOURCE_PATH/usbip-<version>/src/lib
Add Library Path
Add the library path to the environment variables:
$ export LD_LIBRARY_PATH=/usr/local/lib
$ export LD_RUN_PATH=/usr/local/lib
USB/IP Commands
General Usage
$ usbip [options]
Options:
| Command | Description |
|---|---|
-a, --attach [host] [bus_id] |
Attach a remote USB device. |
-x, --attachall [host] |
Attach all remote USB devices from a specific host. |
-d, --detach [ports] |
Detach an imported USB device. |
-l, --list [hosts] |
List exported USB devices. |
-p, --port |
Display virtual USB port status. |
-D, --debug |
Print debugging information. |
-v, --version |
Show the version of USB/IP. |
-h, --help |
Display help information. |
Managing Modules
Check Module Status
$ lsmod | grep usbip
Load Modules
Load USB/IP modules using:
$ insmod usbip-core.ko
$ insmod usbip-host.ko
$ insmod usbip-vudc.ko
$ insmod vhci-hcd.ko
$ insmod usbip_common_mod.ko
$ insmod usbip.ko
USB/IP Server and Client Configuration
Server Configuration
Ensure the USB device is physically connected.
Load required modules:
$ insmod usbip_common_mod.ko # Load common module
$ insmod usbip.ko # Load USB/IP module
- Start the USB/IP daemon:
$ usbipd -D
- List available USB devices:
$ bind_driver --list
- Export a USB device:
$ bind_driver --usbip <bus_id>
Client Configuration
- Load required modules:
$ insmod usbip_common_mod.ko # Load common module
$ insmod vhci-hcd.ko # Load client module
- List USB devices available on the server:
$ usbip --list <server_ip>
- Attach a USB device from the server:
$ usbip --attach <server_ip> <bus_id>
- Check virtual port status:
$ usbip --port
- Detach a USB device:
$ usbip --detach <port>
Example Server Device Connection
To attach a device on the server at IP 10.0.0.3 with bus_id 1-1:
$ usbip --attach 10.0.0.3 1-1