Jump to content
SebbiUltimate

[Script] Unraid USB Device Auto Attach Tool

1 post in this topic Last Reply

Recommended Posts

Posted (edited)

Scenario:
- You want to assign identical devices to each VM

- You don't have multiple USB controllers

- You cannot identify the USB devices by USB vendor and product id

- Amount of VMs could vary and USB device models per type (keyboard, mouse, etc.) could also vary

 

Solution:

This script enumerates all running VMs and assigns each VM the configured devices dynamically. If something changes, like amount of running VMs or the attached devices, just run the script again.

How to use:

1. Install Python from NerdPack

2. Copy the script to your unraid server as usbattach.py and make it executable (chmod +x usbattach.py)

3. Create a file called usbdevices.cfg in the same directory and fill in the device description per device in each line, if the devices of this type are exhausted you can add another device description with semicolon, for example:

Fujitsu Siemens Computers;Holtek Semiconductor, Inc. Keyboard
Logitech, Inc. M90/M100 Optical Mouse
Generalplus Technology Inc.

 

This means that every VM gets a Fujitsu Keyboard, a Logitech mouse and a Generalplus sound device; if the Fujitsu keyboards are exhausted, the next VM gets a Holtek keyboard assigned.

 

4. Run the script. (This can be automated e.g. via SSH plink.exe from putty)

 

Download: https://gist.github.com/SebbiUltimate/bcf61efb9be5bbfc5161097e0d998c9a

Edited by SebbiUltimate

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.