[TUTORIAL] Virtual Pendrive on VM

Sorry for any misunderstanding, I have never configured the above said "USB Device". I'm just trying to go through possible suggestions.
Have you tried to set it within the BIOS of the VM?
So when you boot-up the VM in the console, hit the Esc to enter the BIOS/Boot device menu.
I've tried the BIOS in the VM but it doesn't even have a section to change
 
I've tried the BIOS in the VM but it doesn't even have a section to change
I'm sorry I don't currently have a VM with OVMF bios (in test, non-production scenario) that I can currently reboot to test. But I'm almost sure that in the past I have managed to enter a BIOS/BOOT/SELECTION section of the OVMF bios. If I have a chance I'll try & spin something up to test.
Do you have any screenshots of the BIOS/settings you are able to see?
 
Screenshot 2024-04-01 124459.pngScreenshot 2024-04-01 124539.pngScreenshot 2024-04-01 130655.png


So I spun up a Linux Mint VM on OVMF/UEFI bios - added a Gparted CD Rom image to it. And I'm able to enter the bios settings & boot from whatever.

It would be surprising that you see the USB disk in Windows Disk Management, but not in the BIOS. Maybe some Secure Boot constraint?

EDIT: I also further added a SystemRescue Cd rom, which I know has problems booting in some UEFI scenarios - and yes I couldn't boot from it - but it still showed up in the BIOS.
 
Last edited:
I wish i could add a Pendrive in the GUI.
Lovely & useful idea. Would use it endlessly. Should be implemented with no backup enabled for VM. Should also be "hot swappable" & "insertable" on any VM (not at the same time). Coming to think of it - it shouldn't have any VMID configuration attached to it.
I go on & on asking for everything ......
 
Last edited:
  • Like
Reactions: LostOnTheLine
I followed the tutorial and was able to burn the virtual USB perfectly. Thank you @PanWaclaw !
However, I notice the speed of the interface is terribly low. I checked over VM -> Monitor, the "info usb" and shows me using ubs 1.1:

Code:
Type 'help' for help.
# info usb
  Device 0.1, Port 1, Speed 12 Mb/s, Product QEMU USB Tablet, ID: tablet
  Device 0.2, Port 2, Speed 12 Mb/s, Product QEMU USB Hub
  Device 0.3, Port 2.1, Speed 12 Mb/s, Product QEMU USB MSD, ID: drive-usb0

Does anyone know how can I change it at least to USB 2.0?

Thank you,
 
Does anyone know how can I change it at least to USB 2.0?
I believe your going to need to add a device usb-xhci, and then add device usb-storage to the bus as bus=xhci.0
As per docs.

Note: I've never personally done this or used any virtual USB flash stick, only attempting to help.
 
Thanks @gfngfn256 for suggestion but struggling to get correct parameters / commands. VM don't start bc unable to find out this bus=xhci.0 :(
I mitigated it adding usb0 as SPICE (don't know why) but only to 100Mb... it is really paintful process if can not get USB2.0 or even better USB3.1 to move data around
 
but struggling to get correct parameters / commands
Again I've never done this, but how about (based on @PanWaclaw advice in first post):

1. Create Flash Drive image:
Bash:
dd bs=1G count=8 if=/dev/zero of=/tmp/usb0.img

2. Add a drive device for our flash drive [VM --> Monitor]:
Code:
drive_add 0 file=/tmp/usb0.img,if=none,id=drive-usb0,format=raw,cache=none

3. Add a USB xhci bus [VM --> Monitor]:
Code:
device_add nec-usb-xhci,id=xhci

4. Install our flash drive in the slot on the xhci bus [VM --> Monitor]:
Code:
device_add usb-storage,bus=xhci.0,drive=drive-usb0,removable=on

I'd really be interested to know, if this works.

EDIT: For my own reference (based on test case of user in coming posts) - changed step 4 from:
Code:
device_add usb-storage,bus=xhci.0,id=drive-usb0,drive=drive-usb0,removable=on
 
Last edited:
  • Like
Reactions: Kingneutron
Again I've never done this, but how about (based on @PanWaclaw advice in first post):

1. Create Flash Drive image:
Bash:
dd bs=1G count=8 if=/dev/zero of=/tmp/usb0.img

2. Add a drive device for our flash drive [VM --> Monitor]:
Code:
drive_add 0 file=/tmp/usb0.img,if=none,id=drive-usb0,format=raw,cache=none

3. Add a USB xhci bus [VM --> Monitor]:
Code:
device_add nec-usb-xhci,id=xhci

4. Install our flash drive in the slot on the xhci bus [VM --> Monitor]:
Code:
device_add usb-storage,bus=xhci.0,id=drive-usb0,drive=drive-usb0,removable=on

I'd really be interested to know, if this works.
Everything works well but step 4. I get the following error:
Code:
# device_add usb-storage,bus=xhci.0,id=drive-usb0,drive=drive-usb0,removable=on
Error: Property 'usb-storage.drive' can't find value 'drive-usb0'

However, if I run this similar command without "bus=xhci.0" it works
Code:
device_add usb-storage,id=drive-usb0,drive=drive-usb0,removable=on

Thanks,
 
However, if I run this similar command without "bus=xhci.0" it works
Have you checked speeds with this.

How about you replace command number 4, with:
Code:
device_add usb-storage,bus=xhci.0,drive=drive-usb0,removable=on
& then check speeds.
 
@gfngfn256 thank you! it worked! and also figure out way bc q35 machines have slightly difference (always enabling USB3.0 performance).
Let me summarize:

  • SeaBIOS machines (I can do it over VM>Monitor, requires VM running)
Code:
drive_add 0 file=/tmp/usb0.img,if=none,id=drive-usb0,format=raw,cache=none
device_add nec-usb-xhci,id=xhci
device_add usb-storage,bus=xhci.0,drive=drive-usb0,removable=on

  • Q35 machines which support UEFI (got it working only using args)
Code:
args: -drive file=/tmp/usb0.img,if=none,id=drive-usb0,format=raw,cache=none -device pcie-root-port,id=root,slot=0 -device nec-usb-xhci,id=xhci -device usb-storage,bus=xhci.0,drive=drive-usb0,removable=on

With Q35 machines, I can create personalized windows 11 images using rufus and load it without need of having physical USB.
Thank you!
 

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!