[SOLVED] Forwarding usb to a virtual machine

Vitaly_KoT

New Member
Oct 7, 2020
7
0
1
36
Please tell me. It is impossible to forward 6 USB flash drives to a virtual machine, maximum 5 usb. Sorry for the translation, I am translating via google translator.
Proxmox 6.2
Guest OS: Windows 2012
I was looking for a solution through Google, they write that you can unlock the number of connected USBs, but how to do it?
 
Last edited:

Stefan_R

Proxmox Retired Staff
Retired Staff
Jun 4, 2019
1,300
280
88
Vienna
  1. Use PCI passthrough to assign the VM an entire USB controller, then you can connect as much as you want
  2. Pass through not the device, but a port, and use a USB hub
  3. Edit /usr/share/perl5/PVE/QemuServer.pm and increase $MAX_USB_DEVICES, then reboot or restart pve services (not recommended since it will be reset on upgrade, might break other things, and will most likely still not work via the GUI, only CLI)
Keep in mind that all options other than 1. will limit your bandwidth, as all USB traffic has to go through the host user space first. High-bandwidth applications like audio or video devices might not work correctly.
 
  • Like
Reactions: Vitaly_KoT

Vitaly_KoT

New Member
Oct 7, 2020
7
0
1
36
  1. Use PCI passthrough to assign the VM an entire USB controller, then you can connect as much as you want
  2. Pass through not the device, but a port, and use a USB hub
  3. Edit /usr/share/perl5/PVE/QemuServer.pm and increase $MAX_USB_DEVICES, then reboot or restart pve services (not recommended since it will be reset on upgrade, might break other things, and will most likely still not work via the GUI, only CLI)
Keep in mind that all options other than 1. will limit your bandwidth, as all USB traffic has to go through the host user space first. High-bandwidth applications like audio or video devices might not work correctly.
Thanks, I will try.
 

leesteken

Famous Member
May 31, 2020
2,345
499
88
  • Pass through not the device, but a port, and use a USB hub
Can you please show me how to do that? I could not find it in the manual. Maybe I did not look in the right place?
If a pass through a port (usb1: host=1-13), it will work for any single device connected to it. However, when I connect a USB-hub, the VM does not see the devices.
I need to pass through each device connected to the hub separately ((usb1: host=1-13.1 usb2: host=1-13.2 usb3: host=1-13.3)), to make it work and run over 5 quickly.

I did find a work-around using something like pvesh create "/nodes/${HOSTNAME}/qemu/${VMID}/monitor" --command device_add usb-host,bus=xhci.0,hostbus=1,hostport=13.3,id=${DEVID} in /etc/udev/rules/ to automatically add any number of devices to a VM when detected by the host on a hub on a specific USB-port. But passing through the USB-hub would be much easier.
 
  • Like
Reactions: doge

Stefan_R

Proxmox Retired Staff
Retired Staff
Jun 4, 2019
1,300
280
88
Vienna
Can you please show me how to do that? I could not find it in the manual. Maybe I did not look in the right place?
If a pass through a port (usb1: host=1-13), it will work for any single device connected to it. However, when I connect a USB-hub, the VM does not see the devices.
Ah does it not work? Sorry, my mistake then, I was under the impression QEMU could cope with that...

Not sure how you could do that then, I'm afraid.
 
  • Like
Reactions: leesteken

Vitaly_KoT

New Member
Oct 7, 2020
7
0
1
36
  1. Use PCI passthrough to assign the VM an entire USB controller, then you can connect as much as you want
  2. Pass through not the device, but a port, and use a USB hub
  3. Edit /usr/share/perl5/PVE/QemuServer.pm and increase $MAX_USB_DEVICES, then reboot or restart pve services (not recommended since it will be reset on upgrade, might break other things, and will most likely still not work via the GUI, only CLI)
Keep in mind that all options other than 1. will limit your bandwidth, as all USB traffic has to go through the host user space first. High-bandwidth applications like audio or video devices might not work correctly.
thanks again, everything works.
 

doge

New Member
Apr 5, 2022
6
1
3
Can you please show me how to do that? I could not find it in the manual. Maybe I did not look in the right place?
If a pass through a port (usb1: host=1-13), it will work for any single device connected to it. However, when I connect a USB-hub, the VM does not see the devices.
I need to pass through each device connected to the hub separately ((usb1: host=1-13.1 usb2: host=1-13.2 usb3: host=1-13.3)), to make it work and run over 5 quickly.

I did find a work-around using something like pvesh create "/nodes/${HOSTNAME}/qemu/${VMID}/monitor" --command device_add usb-host,bus=xhci.0,hostbus=1,hostport=13.3,id=${DEVID} in /etc/udev/rules/ to automatically add any number of devices to a VM when detected by the host on a hub on a specific USB-port. But passing through the USB-hub would be much easier.

Hello i try to make a bash script to automate mounting a list of usb devices,
is there some code examples somewhere ?
help please :)
 
  1. Use PCI passthrough to assign the VM an entire USB controller, then you can connect as much as you want
  2. Pass through not the device, but a port, and use a USB hub
  3. Edit /usr/share/perl5/PVE/QemuServer.pm and increase $MAX_USB_DEVICES, then reboot or restart pve services (not recommended since it will be reset on upgrade, might break other things, and will most likely still not work via the GUI, only CLI)
Keep in mind that all options other than 1. will limit your bandwidth, as all USB traffic has to go through the host user space first. High-bandwidth applications like audio or video devices might not work correctly.


giving the whole usb controllers on PCI crashed the debian 11 ( proxmox )
 

leesteken

Famous Member
May 31, 2020
2,345
499
88
how do i ?
Code:
show your IOMMU groups.
This give a nice overview: for d in /sys/kernel/iommu_groups/*/devices/*; do n=${d#*/iommu_groups/*}; n=${n%%/*}; printf 'IOMMU group %s ' "$n"; lspci -nns "${d##*/}"; done. Please also show cat /proc/cmdline to check if pcie_acs_override is active, which invalidates the output of the IOMMU groups.

Please move this to another thread as it is only tangentially related to the solved issue of this thread.
 
  • Like
Reactions: rifaterdemsahin

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!