UTM
UTM copied to clipboard
Auto mount USB
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.
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.
:+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
Same same here!
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: @.***>
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)…
Me too! Me too! Exact same issue and hopeful for an auto mount fix!
Has anyone found a solution for this? It would be nice to have the option to mount all serial devices available on startup
Wondering if anyone could advise how this might be achieved in lieu of a nice integrated solution as requested by the OP?
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.
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
utmctltwice, 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
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
utmctltwice, 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.
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
utmctltwice, 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 ?
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
utmctltwice, 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.
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.