Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Script] Unraid USB Device Auto Attach Tool

Featured Replies

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

  • 2 months later...

sounds very interesting but not sure if this is what i want.
i want to ensure that all the usb's connected to the host are passed through to the running VM that have specific GPU passed through.

I of course want to blacklist some devices like the Unraid OS USB drive.

If i shutdown the VM and I run another one that have the gpu passed thourgh the script should mount all the usb's to the new VM.

 

is that possible?

  • Author
53 minutes ago, segator said:

sounds very interesting but not sure if this is what i want.
i want to ensure that all the usb's connected to the host are passed through to the running VM that have specific GPU passed through.

I of course want to blacklist some devices like the Unraid OS USB drive.

If i shutdown the VM and I run another one that have the gpu passed thourgh the script should mount all the usb's to the new VM.

 

is that possible?

Yeah that should work, it maps the devices to all running VMs, so if you shut it down and start another the USB devices should remap to the other VM.

interesting, but this is only for devices in the list(cfg file) right?

so if i'm going to plug new devices I need to update the list?

 

another thing I notice is when I unplug the usb cable sometimes the VM got freeze if I first don't unplug via script

  • Author
47 minutes ago, segator said:

interesting, but this is only for devices in the list(cfg file) right?

so if i'm going to plug new devices I need to update the list?

Yes, so the USB stick for Unraid and other devices will stay unless configured

I notice when  adding a new usb on a running vm with already usb passed thourgh the script disconect all of them and then reconect.

so there are a temporal disconection on already passedtrhough usbs

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.