Difference between revisions of "USB/IP"

From ArchWiki
Jump to navigation Jump to search
(Created English language page for USB/IP)
 
m (Italicize pseudo-variables)
 
(15 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
[[Category:Storage]]
 
[[Category:Storage]]
 +
[[ja:USB/IP]]
 +
[[pt:USB/IP]]
 
From the [http://usbip.sourceforge.net/ USB/IP site]:
 
From the [http://usbip.sourceforge.net/ USB/IP site]:
 
: ''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/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.''
Line 9: Line 11:
 
== Usage ==
 
== Usage ==
  
=== Server Setup ===
+
=== Server setup ===
  
The server should have the physical USB device connected to it.
+
The server should have the physical USB device connected to it, and the {{ic|usbip_host}} USB/IP [[kernel module]] loaded. Then [[start]] and [[enable]] the USB/IP systemd service {{ic|usbipd.service}}.
 
 
Load the USB/IP kernel module:
 
 
 
$ sudo modprobe usbip_host
 
 
 
Start and Enable the USB/IP systemd service:
 
 
 
$ sudo systemctl start usbipd.service
 
$ sudo systemctl enable usbipd.service
 
  
 
List the connected devices:
 
List the connected devices:
Line 36: Line 29:
 
After binding, the device can be accessed from the client.
 
After binding, the device can be accessed from the client.
  
=== Client Setup ===
+
==== Binding with systemd service ====
 +
 
 +
In order to make binding persistent following systemd template unit file can be used:
 +
 
 +
{{hc|/etc/systemd/system/usbip-bind@.service|2=
 +
[Unit]
 +
Description=USB-IP Binding on bus id %I
 +
After=network-online.target usbipd.service
 +
Wants=network-online.target
 +
Requires=usbipd.service
 +
#DefaultInstance=1-1.5
 +
 +
[Service]
 +
Type=simple
 +
ExecStart=/usr/bin/usbip bind -b %i
 +
RemainAfterExit=yes
 +
ExecStop=/usr/bin/usbip unbind -b %i 
 +
Restart=on-failure
 +
 +
[Install]
 +
WantedBy=multi-user.target
 +
}}
 +
 
 +
So, e.g., to share the device having ''busid'' 1-1, one should [[start]] and/or [[enable]] {{ic|usbip-bind@1-1.service}}.
  
Load the VHCI kernel module:
+
=== Client setup ===
  
$ sudo modprobe vhci-hcd
+
Make sure the {{ic|vhci-hcd}} [[kernel module]] is loaded.
  
List devices available on the server:
+
Then list devices available on the server:
  
  $ usbip list -r <Server IP Address>
+
  $ usbip list -r ''server_IP_address''
  
Attach the required device. For example, to attach the device having ''busid'' 1-1.5 :
+
Attach the required device. For example, to attach the device having ''busid'' 1-1.5:
  
  $ usbip attach -r <Server IP Address> -b 1-1.5
+
  $ usbip attach -r ''server_IP_address'' -b 1-1.5
  
=== Disconnecting Devices ===
+
=== Disconnecting devices ===
  
 
A device can be disconnected only after detaching it on the client.
 
A device can be disconnected only after detaching it on the client.
Line 60: Line 76:
 
Detach the device:
 
Detach the device:
  
  $ usbip detach -p <Port Number>
+
  $ usbip detach -p ''port_number''
  
 
Unbind the device on the server:
 
Unbind the device on the server:
  
  $ usbip unbind -b <busid>
+
  $ usbip unbind -b ''busid''
  
{{Note|USB/IP by default requires port 3240 to be open. If a firewall is running, make sure that this port is open. For detailed instruction on configuring the firewall, go to [[Category:Firewalls]
+
{{Note|USB/IP by default requires port 3240 to be open. If a firewall is running, make sure that this port is open. For detailed instruction on configuring the firewall, go to [[:Category:Firewalls]]}}
  
== Man Page ==
+
== Man page ==
  
 
See {{man|8|usbip}}.
 
See {{man|8|usbip}}.
  
== See Also ==
+
== See also ==
  
* [http://usbip.sourceforge.net/ Official USB/IP Project Site]
+
* [http://usbip.sourceforge.net/ Official USB/IP project site]
 
* [https://www.kernel.org/doc/readme/tools-usb-usbip-README Linux Kernel "README for usbip-utils"]
 
* [https://www.kernel.org/doc/readme/tools-usb-usbip-README Linux Kernel "README for usbip-utils"]
 
* [https://developer.ridgerun.com/wiki/index.php?title=How_to_setup_and_use_USB/IP "How To Setup and use USB/IP"]
 
* [https://developer.ridgerun.com/wiki/index.php?title=How_to_setup_and_use_USB/IP "How To Setup and use USB/IP"]

Latest revision as of 16:11, 13 October 2019

From the USB/IP site:

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.

Installation

Install usbip.

Usage

Server setup

The server should have the physical USB device connected to it, and the usbip_host USB/IP kernel module loaded. Then start and enable the USB/IP systemd service usbipd.service.

List the connected devices:

$ usbip list -l

Bind the required device. For example, to share the device having busid 1-1.5:

$ usbip bind -b 1-1.5

To unbind the device:

$ usbip unbind -b 1-1.5

After binding, the device can be accessed from the client.

Binding with systemd service

In order to make binding persistent following systemd template unit file can be used:

/etc/systemd/system/usbip-bind@.service
[Unit]
 Description=USB-IP Binding on bus id %I
 After=network-online.target usbipd.service
 Wants=network-online.target
 Requires=usbipd.service
 #DefaultInstance=1-1.5
 
 [Service]
 Type=simple
 ExecStart=/usr/bin/usbip bind -b %i
 RemainAfterExit=yes
 ExecStop=/usr/bin/usbip unbind -b %i  
 Restart=on-failure
 
 [Install]
 WantedBy=multi-user.target

So, e.g., to share the device having busid 1-1, one should start and/or enable usbip-bind@1-1.service.

Client setup

Make sure the vhci-hcd kernel module is loaded.

Then list devices available on the server:

$ usbip list -r server_IP_address

Attach the required device. For example, to attach the device having busid 1-1.5:

$ usbip attach -r server_IP_address -b 1-1.5

Disconnecting devices

A device can be disconnected only after detaching it on the client.

List attached devices:

$ usbip port

Detach the device:

$ usbip detach -p port_number

Unbind the device on the server:

$ usbip unbind -b busid
Note: USB/IP by default requires port 3240 to be open. If a firewall is running, make sure that this port is open. For detailed instruction on configuring the firewall, go to Category:Firewalls

Man page

See usbip(8).

See also