UTM icon indicating copy to clipboard operation
UTM copied to clipboard

Auto mount USB

Open tobyworks opened this issue 2 years ago • 20 comments

Im using UTM to run Home Assistant in a VM on my mac mini m1, it's been working great so far. However everytime i restart my mac mini i have to manually re mount my Zigbee USB stick, it would be nice that there was some option to enable me to select a USB device and have it auto-mount to the image if the usb device is available so i dont have to resort to janky automation scripts.

tobyworks avatar Jul 26 '23 17:07 tobyworks

I am here to second EXACTLY this use case. If it would just auto-check the found usb stick (remember the checkbox) it would allow for completely attention free operations.

pardeike avatar Aug 13 '23 21:08 pardeike

:+1: to this

right now, you can’t have a headless VM connect to USB devices, as there’s no other UI exposed for mounting them

ascagnel avatar Sep 29 '23 19:09 ascagnel

Same same here!

joelkvarnsmyr avatar Jan 01 '24 14:01 joelkvarnsmyr

No Apple phone.

---- Replied Message ---- | From | @.> | | Date | 01/01/2024 22:52 | | To | @.> | | Cc | @.***> | | Subject | Re: [utmapp/UTM] Auto mount USB (Issue #5497) |

Same same here!

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

q316077570 avatar Jan 01 '24 15:01 q316077570

I’ll add my voice here as well, with the same exact use case as the OP and first comment. There is a desperate need for this feature enhancement!

I imagine it would be trivial to add, in that we just need the already existing UTM code that runs when you check a USB device from the toolbar to also run automatically if a VM-specific preference is checked (the currently non-existent “automount this USB device on boot” option)…

sadpixel avatar Jan 11 '24 14:01 sadpixel

Me too! Me too! Exact same issue and hopeful for an auto mount fix!

rXtwo avatar Mar 22 '24 17:03 rXtwo

Has anyone found a solution for this? It would be nice to have the option to mount all serial devices available on startup

AFreiling avatar May 02 '24 12:05 AFreiling

Wondering if anyone could advise how this might be achieved in lieu of a nice integrated solution as requested by the OP?

NeighNeighNeigh avatar Jun 27 '24 14:06 NeighNeighNeigh

Wondering if anyone could advise how this might be achieved in lieu of a nice integrated solution as requested by the OP?

I wrote a bash script that invokes utmctl twice, first to start my VM, then to attach the USB device.

ascagnel avatar Jun 29 '24 15:06 ascagnel

Wondering if anyone could advise how this might be achieved in lieu of a nice integrated solution as requested by the OP?

I wrote a bash script that invokes utmctl twice, first to start my VM, then to attach the USB device.

Could you provide an example of your batch script please ?

I tried it but cannot get it work.

Here's my code...that doesn't work #!/bin/bash

VM_NAME="HomeAssistant"

USB_DEVICE_1="XXXX:XXXX" USB_DEVICE_2="XXXX:XXXX"

echo "Starting VM..." >> ~/vm_log.txt /Applications/UTM.app/Contents/MacOS/utmctl start "$VM_NAME" if [ $? -ne 0 ]; then echo "Failed to start VM" >> ~/vm_log.txt exit 1 fi

echo "VM started, waiting for it to fully boot..." >> ~/vm_log.txt sleep 20

echo "Attaching USB devices..." >> ~/vm_log.txt /Applications/UTM.app/Contents/MacOS/utmctl attach usb "$VM_NAME" "$USB_DEVICE_1" if [ $? -ne 0 ]; then echo "Failed to attach USB device 1" >> ~/vm_log.txt fi /Applications/UTM.app/Contents/MacOS/utmctl attach usb "$VM_NAME" "$USB_DEVICE_2" if [ $? -ne 0 ]; then echo "Failed to attach USB device 2" >> ~/vm_log.txt fi

echo "USB devices attached." >> ~/vm_log.txt

PatrioteQc avatar Jul 03 '24 21:07 PatrioteQc

Wondering if anyone could advise how this might be achieved in lieu of a nice integrated solution as requested by the OP?

I wrote a bash script that invokes utmctl twice, first to start my VM, then to attach the USB device.

I did the same in an Automator app that opens at login. Works like a charm.

sydrek0 avatar Jul 05 '24 18:07 sydrek0

Wondering if anyone could advise how this might be achieved in lieu of a nice integrated solution as requested by the OP?

I wrote a bash script that invokes utmctl twice, first to start my VM, then to attach the USB device.

I did the same in an Automator app that opens at login. Works like a charm.

Any example of your script so I can do the same ?

PatrioteQc avatar Jul 05 '24 18:07 PatrioteQc

Wondering if anyone could advise how this might be achieved in lieu of a nice integrated solution as requested by the OP?

I wrote a bash script that invokes utmctl twice, first to start my VM, then to attach the USB device.

I did the same in an Automator app that opens at login. Works like a charm.

Any example of your script so I can do the same ?

Mine is very basic, just 4 blocks:

  • Wait 60 sec (just to make sure UTM has started before the script does)
  • Run shell script: /Applications/UTM.app/Contents/MacOS/utmctl start <your VM name>
  • Wait 30 sec (until the HA VM loaded)
  • Run shell script: /Applications/UTM.app/Contents/MacOS/utmctl usb connect <your VM name> <location of your USB device>

Save this as an app. Include in login items. Done. Make sure you also have the UTM app in your login items.

sydrek0 avatar Jul 06 '24 04:07 sydrek0

Hello, I have built a Vagrant plugin for UTM to declartively manage UTM VMs , and I would like to add USB support. This means you can define the USB to connect in the Vagrantfile and then every time you bring up a VM using vagrant up , the USB will be auto-mounted to the VM.

I can add this as a post-boot customization to my plugin and execute utmctl usb connect uuid <device> after the VM is running.

I am thinking I could ask the user for VID:PID pair or a location (since utmctl works with both)

Vagrant.configure("2") do |config|
  config.vm.provider :utm do |u|
    u.utm_file_url = "debian.zip"
    # list of usb to connect
    u.usb = [ "VID:PID" ]
  end
end

Since I have never worked with USB devices, my question what is the best way to ask for USB identifier from the user ?

  • does VID:PID/location change after reboot ?
  • Is there a unique name for a USB device , so I can ask the name and check for it through UTM and connect if available.
utmctl usb list  
Name                    VID :PID   Location
Poly BT600 (0:2)        047F:02EE  2

Suggestions welcome.

naveenrajm7 avatar Aug 12 '24 22:08 naveenrajm7