Automatically pass through a USB device to a VM when plugged in?

smartysmart34

New Member
Jan 30, 2024
5
0
1
Hello all.

I had a search in the forum but i wasn't able to identify that specific question. My Setup:

I just installed a Proxmox host and as I don't have (and don't want) a separate NAS for storage, ONE of the VMs on that host will make an 8TB disk available to my local network via SMB/NFS.
In order to achieve reasonable IO performance I decided to pass through the physical Disk into that VM. With that - I understand - the Proxmox Host does not have Access to that disk anymore and it can not be included into a Backup on Host-Level.

As the same service was previously provided by a physical server, I already do have Backup Scripts that dump config and data to a USB disk. So I would like to just continue plugging my external USB drive in and have it automatically attached to that VM.

The question is: Is there a way to automatically attach a specific (by UUID?) USB Disk into a specific VM once that device is plugged in?
And once the Backup is done and the Device has been unmounted inside the VM, can I then just unplug it?
Except for the initial Setup I would like to avoid any regular Host-Side interaction during the Backup Process - be it via console or GUI.

Any hints/directions? If this is a "No-Go" I would rather consider moving back to physical and then have a bunch of Virtualboxes on top of that...

Thank you and kind regards,
Martin
 
So I would like to just continue plugging my external USB drive in and have it automatically attached to that VM.
You can add a USB device to a VM (when USB hotplug is enabled) via the command line (like running device_add in the QEMU Monitor). You can write udev rules to run a script when a certain USB device is detected. Maybe someone already posted an example on this forum (of each step) or maybe you'll have to write your own.
 
If you passthrough the ports you can plug whatever you want in the guest. However these usb ports will not be available to the host and you can only have one guest attached at a time.
 
If you passthrough the ports you can plug whatever you want in the guest. However these usb ports will not be available to the host and you can only have one guest attached at a time.
That sounds promising and it could be the easy fix for my usecase. Assuming, that once I umount the disk within the guest, there is no other write buffer on Host level. I can then just power off the disk...

By the way: Can I pass-through a single USB socket (like "USB 3.1 top left" - I know I'd have to figure out which exactly that is) , or do I need to pass the entire controller with all attached ports?
 

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 yours easily in our online shop.

Buy now!