Usb over ip: Difference between revisions
No edit summary |
|||
| (19 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== Configurare USB over IP Server pe Ubuntu 2X.04 LTS == | == Configurare USB over IP Server pe Ubuntu 2X.04 LTS == | ||
Intr-un mediu enterprise in care se lucreaza cu foarte multe stiick-uri USB este nevoie ca acestea sa fie plasate intr-un mediu centralizat la care intreaga infrastuctura sa aiba acces. Prin intermediul USBIP stick-urile pot fi plasate intr-o singura locatie indiferent daca acestea sunt stick-uri de stocare, certificate SSL, semnaturi digitale, YubiKey-uri | Intr-un mediu enterprise in care se lucreaza cu foarte multe stiick-uri USB este nevoie ca acestea sa fie plasate intr-un mediu centralizat la care intreaga infrastuctura sa aiba acces. Prin intermediul USBIP stick-urile pot fi plasate intr-o singura locatie indiferent daca acestea sunt stick-uri de stocare, certificate SSL, semnaturi digitale, YubiKey-uri, modem 4G/5G sau Web Camera. | ||
===== Instalare usbip ===== | ===== Instalare usbip ===== | ||
| Line 6: | Line 6: | ||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | <code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | ||
-->apt install linux-tools-generic | --> # apt install linux-tools-generic | ||
</code> | </code> | ||
| Line 12: | Line 12: | ||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | <code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | ||
-->lsmod | grep usbip | --> # lsmod | grep usbip | ||
</code> | </code> | ||
| Line 18: | Line 18: | ||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | <code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | ||
-->apt install linux-tools-5.15.0-43-generic linux-cloud-tools-5.15.0-43-generic | --> # apt install linux-tools-5.15.0-43-generic linux-cloud-tools-5.15.0-43-generic | ||
</code> | |||
====== Module usbip ====== | |||
USBIP are nevoie de 3 module dintre care doua de USB/IP si unul de virtual host controller | |||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | |||
--> # modprobe usbip_core | |||
 # modprobe usbip_host | |||
 # modprobe vhci_hcd | |||
</code> | |||
Pentru ca aceste module sa fie activate la startup-ul de OS se adauga in lista de module incarcabile: | |||
* nano /etc/modules-load.d/modules.conf | |||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | |||
--> usbip_core | |||
 usbip_host | |||
 vhci_hcd | |||
</code> | </code> | ||
| Line 26: | Line 45: | ||
* nano /etc/systemd/system/usbipd.service | * nano /etc/systemd/system/usbipd.service | ||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | <code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | ||
-->[Unit] | --> [Unit] | ||
Description= |  Description=USBIP Host Server | ||
After=network.target |  After=network.target | ||
  | |||
[Service] |  [Service] | ||
ExecStart=/usr/bin/usbipd -D |  ExecStart=/usr/bin/usbipd -D | ||
ExecStop=/usr/bin/usbip --tcp-port 3240 --log |  ExecStop=/usr/bin/usbip --tcp-port 3240 --log | ||
Restart=on-failure |  Restart=on-failure | ||
User=root |  User=root | ||
Type=forking |  Type=forking | ||
StartLimitBurst=5 |  StartLimitBurst=5 | ||
StartLimitIntervalSec=10 |  StartLimitIntervalSec=10 | ||
  | |||
[Install] |  [Install] | ||
WantedBy=multi-user.target |  WantedBy=multi-user.target | ||
</code> | </code> | ||
| Line 49: | Line 67: | ||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | <code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | ||
--># systemctl enable --now usbipd.service | --> # systemctl enable --now usbipd.service | ||
 # systemctl status usbipd.service |  # systemctl status usbipd.service | ||
<span style="color:#0f0">●</span> usbipd.service - USB/IP Host Service |  <span style="color:#0f0">●</span> usbipd.service - USB/IP Host Service | ||
  Loaded: loaded (/etc/systemd/system/usbipd.service; enabled; vendor preset: enabled) |   Loaded: loaded (/etc/systemd/system/usbipd.service; enabled; vendor preset: enabled) | ||
  Active: <span style="color:#0f0">active (running)</span> since Fri 2024-04-12 18:03:02 EEST; 25min ago |   Active: <span style="color:#0f0">active (running)</span> since Fri 2024-04-12 18:03:02 EEST; 25min ago | ||
| Line 61: | Line 79: | ||
</code> | </code> | ||
====== | ===== Adaugare dispozitive USB server ===== | ||
Din acest moment dispozitivele USB pot fi adaugate in system. | |||
Mai jos este prezentat modul in care se face passtrue dispozitivelor USB intr-un hypervisor Proxmox VM | |||
<gallery> | |||
File:USB_over_IP_via_Proxmox_VM_01.jpeg | |||
File:USB_over_IP_via_Proxmox_VM_02.jpeg | |||
File:USB_over_IP_via_Proxmox_VM_03.jpeg | |||
</gallery> | |||
Dupa ce dispozitivele USB sunt adaugate fizis se trece la atasarea acestora in server: | |||
====== Listare dispozitive USB ====== | |||
Listam dispozitivele USB atasate cu comanda lsusb: | |||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | |||
--> # lsusb | |||
 Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub | |||
 Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub | |||
 <b>Bus 002 Device 005: ID 090c:1000 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) Flash Drive</b> | |||
 <b>Bus 002 Device 002: ID 13fe:4200 Kingston Technology Company Inc. Platinum USB drive mini</b> | |||
</code> | |||
Pentru a vedea ce dispozitive pot fi parsate de catre aplicatie rulam: | |||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | |||
--> # usbip list -p -l | |||
 busid=2-2#usbid=13fe:4200# | |||
 busid=2-4#usbid=090c:1000# | |||
</code> | |||
====== Atasarea dispozitive USB ====== | |||
Pentru a afla BUSID-ul fiecatui dispozitiv asa cum este inregistrat de usbip rulam: | |||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | |||
--> # usbip list -l | |||
  - busid 2-2 (13fe:4200) | |||
  Kingston Technology Company Inc. : Platinum USB drive mini (13fe:4200) | |||
  | |||
  - busid 2-4 (090c:1000) | |||
  Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) : Flash Drive (090c:1000) | |||
</code> | |||
Vom atasa serverului cele doua dispozitive listate anterior: | |||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | |||
--> # usbip bind -b 2-2 | |||
 usbip: info: bind device on busid 2-2: complete | |||
 # usbip bind -b 2-4 | |||
 usbip: info: bind device on busid 2-4: complete | |||
</code> | |||
====== Atasarea dispozitive USB la pornirea OS ====== | |||
Pentru binding-ul dispozitivelor USB la pornirea de OS se ceeaza cate un serviciu de sistemd pentru fiecare dispozitiv in parte: | |||
* nano /etc/systemd/system/usbip_bus22.service | |||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | |||
--> [Unit] | |||
 Description=USB-IP Device Binding BUS 2-2 | |||
 After=network-online.target | |||
 Wants=network-online.target | |||
 Requires=usbipd.service | |||
  | |||
 [Service] | |||
 Type=oneshot | |||
 ExecStart=/usr/bin/usbip bind --busid 2-2 | |||
  | |||
 [Install] | |||
 WantedBy=multi-user.target | |||
  | |||
 # systemctl enable usbip_bus22.service | |||
</code> | |||
<nowiki>*</nowiki> '''Requires=usbipd.service''' este adaugat pentru ca bind-ul sa fie facut dupa ponirea aplicatiei de usbip | |||
<nowiki>*</nowiki> '''Type=oneshot''' bind-ul este o actiune de se executa o singura data. Ne fiind un serviciu in sine systemctl '''status usbip_bus22.service''' va arata serviciul ca '''dead''' dar actiunea de bind este indeplinits | |||
== Configurare USB over IP Client pe Ubuntu 2X.04 LTS == | |||
===== Instalare usbip ===== | |||
Instalarea de usbip client se face la fel ca si cea de server inclusiv modulele insa nu mai este cazul ca serviciul de systemd sa fie activat | |||
===== Listare dispozitive USB ===== | |||
Inainte de a atasa un dispozitiv USB montat din server facem o listare a dispozitivelor deja existente. | |||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | |||
--> # lsusb | |||
 Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd QEMU USB Tablet | |||
 Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub | |||
</code> | |||
... iar apoi listam dispozitivele disponibile in server | |||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | |||
--> # usbip list -r 192.168.1.203 | |||
 Exportable USB devices | |||
 ====================== | |||
  - 192.168.1.203 | |||
  2-4: Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) : Flash Drive (090c:1000) | |||
  : /sys/devices/pci0000:00/0000:00:1e.0/0000:02:1b.0/usb2/2-4 | |||
  : (Defined at Interface level) (00/00/00) | |||
  | |||
  2-2: Kingston Technology Company Inc. : Platinum USB drive mini (13fe:4200) | |||
  : /sys/devices/pci0000:00/0000:00:1e.0/0000:02:1b.0/usb2/2-2 | |||
  : (Defined at Interface level) (00/00/00) | |||
</code> | |||
===== Atasarea dispozitive USB ===== | |||
Dupa identificarea busid-ului fiecarui dispozitiv disponibil in server (2-2 si 2-4 in cazul de fata), atasam dispozitivele USB la masina client | |||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | <code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | ||
--> | --> # usbip attach -r 192.168.1.203 -b 2-2 | ||
 # usbip attach -r 192.168.1.203 -b 2-4 | |||
</code> | </code> | ||
... si verificam faptul ca acestea au fost atasate: | |||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | |||
--> # usbip port -l | |||
 Imported USB devices | |||
 ==================== | |||
 Port 00: <Port in Use> at High Speed(480Mbps) | |||
  Kingston Technology Company Inc. : Platinum USB drive mini (13fe:4200) | |||
  2-1 -> usbip://192.168.1.203:3240/2-2 | |||
  -> remote bus/dev 002/002 | |||
 Port 01: <Port in Use> at High Speed(480Mbps) | |||
  Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) : Flash Drive (090c:1000) | |||
  2-2 -> usbip://192.168.1.203:3240/2-4 | |||
  -> remote bus/dev 002/003 | |||
</code> | |||
... iar apoi verificam dispozitivele usb disponibile in masina virtuala: | |||
<code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | <code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | ||
--> | --> # lsusb | ||
 Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub | |||
 '''Bus 002 Device 003: ID 090c:1000 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) Flash Drive''' | |||
 '''Bus 002 Device 002: ID 13fe:4200 Kingston Technology Company Inc. Platinum USB drive mini''' | |||
 Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub | |||
 Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd QEMU USB Tablet | |||
 Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub | |||
</code> | </code> | ||
===== | ====== Atasarea dispozitive USB la pornirea OS ====== | ||
Pentru binding-ul dispozitivelor USB la pornirea de OS se ceeaza cate un serviciu de sistemd pentru fiecare dispozitiv in parte: | |||
* nano /etc/systemd/system/usbip_bus22.service | |||
< | <code class="mw-code mw-highlight plainlinks" style="display:block"><!-- | ||
--> [Unit] | |||
 Description=USB-IP Device Binding BUS 2-2 | |||
 After=network-online.target | |||
</ |  Wants=network-online.target | ||
  | |||
 [Service] | |||
 Type=oneshot | |||
 ExecStart=/usr/bin/usbip attach -r 192.168.1.203 -b 2-4 | |||
  | |||
 [Install] | |||
 WantedBy=multi-user.target | |||
  | |||
 # systemctl enable usbip_bus22.service | |||
</code> | |||
Latest revision as of 16:29, 14 April 2024
Configurare USB over IP Server pe Ubuntu 2X.04 LTS[edit | edit source]
Intr-un mediu enterprise in care se lucreaza cu foarte multe stiick-uri USB este nevoie ca acestea sa fie plasate intr-un mediu centralizat la care intreaga infrastuctura sa aiba acces. Prin intermediul USBIP stick-urile pot fi plasate intr-o singura locatie indiferent daca acestea sunt stick-uri de stocare, certificate SSL, semnaturi digitale, YubiKey-uri, modem 4G/5G sau Web Camera.
Instalare usbip[edit | edit source]
USBIP face parte in Ubuntu 2X.44 din luita de tool-uri linux-tools-generic. Pentru instalare se executa in consola:
# apt install linux-tools-generic
Se verifica daca kernelul are modulele disponibile:
# lsmod | grep usbip
...in unele situatii fiind necesara instalarea unor pachete specifice:
# apt install linux-tools-5.15.0-43-generic linux-cloud-tools-5.15.0-43-generic
Module usbip[edit | edit source]
USBIP are nevoie de 3 module dintre care doua de USB/IP si unul de virtual host controller
# modprobe usbip_core
# modprobe usbip_host
# modprobe vhci_hcd
Pentru ca aceste module sa fie activate la startup-ul de OS se adauga in lista de module incarcabile:
- nano /etc/modules-load.d/modules.conf
usbip_core
usbip_host
vhci_hcd
Startup usbip[edit | edit source]
Pentru ca aplicatia sa porneasca la odata cu systemului de operare se creeaza un fisier de startup un systemctl
- nano /etc/systemd/system/usbipd.service
[Unit]
Description=USBIP Host Server
After=network.target
[Service]
ExecStart=/usr/bin/usbipd -D
ExecStop=/usr/bin/usbip --tcp-port 3240 --log
Restart=on-failure
User=root
Type=forking
StartLimitBurst=5
StartLimitIntervalSec=10
[Install]
WantedBy=multi-user.target
Dupa creerea serviciului se executa:
# systemctl enable --now usbipd.service
# systemctl status usbipd.service
● usbipd.service - USB/IP Host Service
Loaded: loaded (/etc/systemd/system/usbipd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2024-04-12 18:03:02 EEST; 25min ago
Process: 696 ExecStart=/usr/bin/usbipd -D (code=exited, status=0/SUCCESS)
Main PID: 728 (usbipd)
Tasks: 1 (limit: 2220)
Memory: 800.0K
CPU: 18ms
Adaugare dispozitive USB server[edit | edit source]
Din acest moment dispozitivele USB pot fi adaugate in system. Mai jos este prezentat modul in care se face passtrue dispozitivelor USB intr-un hypervisor Proxmox VM
Dupa ce dispozitivele USB sunt adaugate fizis se trece la atasarea acestora in server:
Listare dispozitive USB[edit | edit source]
Listam dispozitivele USB atasate cu comanda lsusb:
# lsusb
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 005: ID 090c:1000 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) Flash Drive
Bus 002 Device 002: ID 13fe:4200 Kingston Technology Company Inc. Platinum USB drive mini
Pentru a vedea ce dispozitive pot fi parsate de catre aplicatie rulam:
# usbip list -p -l
busid=2-2#usbid=13fe:4200#
busid=2-4#usbid=090c:1000#
Atasarea dispozitive USB[edit | edit source]
Pentru a afla BUSID-ul fiecatui dispozitiv asa cum este inregistrat de usbip rulam:
# usbip list -l
- busid 2-2 (13fe:4200)
Kingston Technology Company Inc. : Platinum USB drive mini (13fe:4200)
- busid 2-4 (090c:1000)
Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) : Flash Drive (090c:1000)
Vom atasa serverului cele doua dispozitive listate anterior:
# usbip bind -b 2-2
usbip: info: bind device on busid 2-2: complete
# usbip bind -b 2-4
usbip: info: bind device on busid 2-4: complete
Atasarea dispozitive USB la pornirea OS[edit | edit source]
Pentru binding-ul dispozitivelor USB la pornirea de OS se ceeaza cate un serviciu de sistemd pentru fiecare dispozitiv in parte:
- nano /etc/systemd/system/usbip_bus22.service
[Unit]
Description=USB-IP Device Binding BUS 2-2
After=network-online.target
Wants=network-online.target
Requires=usbipd.service
[Service]
Type=oneshot
ExecStart=/usr/bin/usbip bind --busid 2-2
[Install]
WantedBy=multi-user.target
# systemctl enable usbip_bus22.service
* Requires=usbipd.service este adaugat pentru ca bind-ul sa fie facut dupa ponirea aplicatiei de usbip
* Type=oneshot bind-ul este o actiune de se executa o singura data. Ne fiind un serviciu in sine systemctl status usbip_bus22.service va arata serviciul ca dead dar actiunea de bind este indeplinits
Configurare USB over IP Client pe Ubuntu 2X.04 LTS[edit | edit source]
Instalare usbip[edit | edit source]
Instalarea de usbip client se face la fel ca si cea de server inclusiv modulele insa nu mai este cazul ca serviciul de systemd sa fie activat
Listare dispozitive USB[edit | edit source]
Inainte de a atasa un dispozitiv USB montat din server facem o listare a dispozitivelor deja existente.
# lsusb
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd QEMU USB Tablet
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
... iar apoi listam dispozitivele disponibile in server
# usbip list -r 192.168.1.203
Exportable USB devices
======================
- 192.168.1.203
2-4: Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) : Flash Drive (090c:1000)
: /sys/devices/pci0000:00/0000:00:1e.0/0000:02:1b.0/usb2/2-4
: (Defined at Interface level) (00/00/00)
2-2: Kingston Technology Company Inc. : Platinum USB drive mini (13fe:4200)
: /sys/devices/pci0000:00/0000:00:1e.0/0000:02:1b.0/usb2/2-2
: (Defined at Interface level) (00/00/00)
Atasarea dispozitive USB[edit | edit source]
Dupa identificarea busid-ului fiecarui dispozitiv disponibil in server (2-2 si 2-4 in cazul de fata), atasam dispozitivele USB la masina client
# usbip attach -r 192.168.1.203 -b 2-2
# usbip attach -r 192.168.1.203 -b 2-4
... si verificam faptul ca acestea au fost atasate:
# usbip port -l
Imported USB devices
====================
Port 00: <Port in Use> at High Speed(480Mbps)
Kingston Technology Company Inc. : Platinum USB drive mini (13fe:4200)
2-1 -> usbip://192.168.1.203:3240/2-2
-> remote bus/dev 002/002
Port 01: <Port in Use> at High Speed(480Mbps)
Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) : Flash Drive (090c:1000)
2-2 -> usbip://192.168.1.203:3240/2-4
-> remote bus/dev 002/003
... iar apoi verificam dispozitivele usb disponibile in masina virtuala:
# lsusb
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 003: ID 090c:1000 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) Flash Drive
Bus 002 Device 002: ID 13fe:4200 Kingston Technology Company Inc. Platinum USB drive mini
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd QEMU USB Tablet
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Atasarea dispozitive USB la pornirea OS[edit | edit source]
Pentru binding-ul dispozitivelor USB la pornirea de OS se ceeaza cate un serviciu de sistemd pentru fiecare dispozitiv in parte:
- nano /etc/systemd/system/usbip_bus22.service
[Unit]
Description=USB-IP Device Binding BUS 2-2
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/usbip attach -r 192.168.1.203 -b 2-4
[Install]
WantedBy=multi-user.target
# systemctl enable usbip_bus22.service