Once you have basic GPU passthrough configured, you can get near bare-metal performance in a VM on Unraid using KVM under the hood. However, one thing that is a little awkward are USB devices. The host, in this case Unraid, owns, initializes, and configures USB devices by default. This gets even more complicated when you consider that Unraid boots off a USB device rather than another drive in the system.
Here we’ll look at how you can get close to hot-plugging USB devices into a VM. In a future post we’ll take it a step further to get near-baremetal functionality just like we did with the GPU.
Static Configuration
The most basic configuration is useful if you have USB devices that will be plugged in all the time. This is then easy to configure and connect these to your VM is directly through Unraid’s GUI. In order to do this, make sure you have all your USB devices plugged into your machine that you plan to pass through to the VM. USB devices will then show up directly in the VM settings as below:
You can then select which USB devices you’d like to pass through and update your VM configuration. Each time your VM boots Unraid will assign these USB devices to your VM automatically.
However, Unraid prevents you from changing this configuration once the VM is running. Then, how do you assign devices to that running VM?
Hot Plug Plugin
In order to get a little more configurable, there are some Community Applications / Plugins that can help. In order to use these you’ll have to install the Community Applications plugin. Our target here is the Hotplug USB App:
Once you have this plugin installed, you’ll see a new configuration section under the VM tab in Unraid. Once a VM is running it will show up in the Running VM list, and any unassigned USB devices will show up in the USB Devices list. Whenever a new device is plugged in, you will sometimes have to click Refresh at the bottom of the page in order for it to show up in the list of devices.
In order to assign a device to a VM, it’s as simple as selecting the device in the USB Devices drop-down and the VM you’d like to attach it to in the Running VMs drop-down and clicking Attach.
As the note at the bottom of the page will say, sometimes you will need to Attach / Detach / re-Attach the device in order for it to be correctly detected. I have also noticed that some devices have their own internal hubs, which mean that they may show another device once initialized. I especially encountered this issue when plugging in my Thrustmaster T300 racing wheel. When plugged in, Unraid showed one device at first “Thrustmaster FFB Device”. Unraid then showed another device: “Thrustmaster T300 Wheel”. The wheel worked only once both of these devices were connected.
Conclusion
These two configurations are the most basic configurations that you can have with USB devices and a VM in Unraid. This gets you about 50% of the way to a bare-metal feeling VM. However, this configuration leaves some functionality on the table:
- A manual operation must be performed whenever a new device is added to the VM.
- The Unraid menu must be used to do the assignment.
- A USB controller cannot be assigned in this manner.
We can solve most of these problems by passing through an entire USB controller in a different way in a future post.
Hi Evan,
Did you try to passthrough the controller instead the devices? I think it could solve our problems. I will try ASAP:
https://forums.unraid.net/topic/35112-guide-passthrough-entire-pci-usb-controller/
Kind regards.
Yes, I was writing up further posts about that because it’s often difficult to figure out what controller corresponds to which ports, etc. I described a bit of this here: http://www.elaske.com/x370-motherboard-pci-iommu-mapping/. I just never finished my post about the controller pass-through. I’m now motivated to finish that!