*NOTE: While technically the name of the XML file can be anything, keeping this naming scheme is necessary for the scripts we'll be creating later on in this guide. Replace the 0's with the Vendor ID and the a's with the Model ID from the last section. We're now going to create a Libvirt (QEMU Management Library) XML Config file called usb-0000-aaaa.xml in the /etc/libvirt/qemu/USB directory which will define the USB device for the VM. Remember these values as we'll be needing them in the upcoming sections. Udevadm info /dev/bus/usb/BusID/DeviceID | egrep "ID_VENDOR=|ID_MODEL=|PRODUCT" For example, if your Bus ID is 001 and your Device ID is 005 your command will be udevadm info /dev/bus/usb/ 001/ 005 | egrep "ID_VENDOR=|ID_MODEL=|PRODUCT". Next run the following, to get the Vendor ID, Model ID & Product ID of your USB device substituting the Bus & Device ID #'s from the last command. In the output, locate the USB device and note the Bus & Device ID #'s. Inside the terminal window, run the following command to identify your USB device. *TIP: For those more hardcore or if you're running an older version of unRAID missing this option, you can ssh to your unRAID server as root with your favorite SSH client. Identify Your USB DeviceĪfter logging in, click on the Terminal icon at the top of the page. The easiest way to achieve this is by opening a web browser and logging into the unRAID management GUI. You can do this by gaining console access to your unRAID server. The first thing we need to do is obtain the ID's of the device or devices you'd like to have hotplugged to your VM. *UPDATE (3/20/20): This guide has been updated and tested to work with later versions of unRAID 6.8 & 6.9. If you're using libvirt on a non-unRAID server while hotplugging a single USB device directly into the VM host, their guide may be better suited to you. I developed this method after stumbling upon this helpful post, Automatic hotplugging of USB devices for libvirt-managed VMs at.
This can wreck havoc on a script that relies on these events to launch itself and it's one of the reasons why my previous solution stopped working.ĭon't fret, as after much trial and error, I believe I have a working yet, somewhat convulated way to automatically attach and detach your USB devices to your VM's. I'm not quite sure why this is, but while monitoring udev, Linux's device manager, I would see my mouse and keyboard rapidly attach and detach several times in less than a second. Like I said before, major hassle.Īnother complication when using a USB switch, at least in my case, is everytime you cycle the USB switch away from the unRAID server, multiple add and remove events are detected.
With the currently available plugins, this means you'd always need a second PC handy to access the unRAID GUI and reassociate your keyboard and mouse. Anytime you cycle the switch away from a PC, the USB device, like say a keyboard or mouse, will act as if its been unplugged. However, like a KVM switch, it allows you to hookup any USB device to multiple PC's at once, but only one PC can see the device at a time. The only difference is it lacks the video portion. While this isn't so bad when you need to plug in an occassional USB thumb drive, it becomes a much bigger hassle when you throw a USB switch and multiple devices into the mix.įor those who are unaware, a USB switch is like a KVM.not the KVM related to VM's, but the Keyboard/Video/Mouse kind. There have been a couple of good souls that have written plugins that allow you to manually add a USB device to a running VM, but it requires that you login to the unRAID management GUI everytime you want this done. Well, after several years and numerous unRAID upgrades, not only am I still waiting for this feature, but the solution I was using stopped working. I wasn't ever planning on revisiting this issue as unRAID was supposed to implement this as a feature in a future release.
A long time ago, I figured out how to have an unRAID server detect a hotplugged USB device and automatically associate this device with a VM.