Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run .utm from anywhere #1205

Closed
phsimons opened this issue Dec 4, 2020 · 38 comments
Closed

Run .utm from anywhere #1205

phsimons opened this issue Dec 4, 2020 · 38 comments
Labels
enhancement New feature or request macOS macOS issues
Milestone

Comments

@phsimons
Copy link

phsimons commented Dec 4, 2020

It would be nice to be able to store the .utm VMs some where else than ~\Documents, for exemple an attached disk.

Version
2.0.13(13)

@osy osy changed the title Request for enhancement Run .utm from anywhere Dec 6, 2020
@osy osy added the enhancement New feature or request label Dec 6, 2020
@thebitstick
Copy link

This is especially important when using iCloud and it tries to backup .utm VMs :/

@stefandesu
Copy link

Yeah, I just had the same thought when iCloud started uploading the VM...

@thebitstick
Copy link

Workaround: quit UTM, move your .utm bundles elsewhere, and the symlink them to your Documents folder.
This will need to be done manually for every VM you create, but at least you don't use up your iCloud storage.

@ty-yqs
Copy link
Contributor

ty-yqs commented Dec 26, 2020

Yeah, I just had the same thought when iCloud started uploading the VM...

But .utm files are usually very large. So if you don’t download .utm file in iCloud, it will become very slow to open this file.

@stefandesu
Copy link

Yeah, I just had the same thought when iCloud started uploading the VM...

But .utm files are usually very large. So if you don’t download .utm file in iCloud, it will become very slow to open this file.

The issue is about not having the files in iCloud in the first place. ;) Simply said, we want to be able to choose where the VMs are stored because the Documents folder is often synced via iCloud Drive.

@osy osy added the macOS macOS issues label Jan 1, 2021
@sulliops
Copy link

Definitely want this feature, running VMs off external drives is the biggest reason why for me.

Workaround: quit UTM, move your .utm bundles elsewhere, and the symlink them to your Documents folder.
This will need to be done manually for every VM you create, but at least you don't use up your iCloud storage.

Just for anyone that might be confused as to how to do this, the command for Terminal is as follows:

ln -s /path/to/original /path/to/link

@jpc
Copy link

jpc commented Mar 21, 2021

Hi,

In the newest (non App Store) version the symlink works only if the VM is located on the system disk. If I move the .utm bundle to an external USB disk (APFS formatted) and create the symlink, the VM does not show in the UI at all.

I also tried to symlink the qcow2 files inside the .utm bundle but I get errors when trying to start the VM:

libqemu-aarch64-softmmu.utm.dylib: -drive if=virtio,media=disk,id=drive0,file=/Users/jpc/Library/Containers/com.utmapp.UTM/Data/Documents/Debian ARM.utm/Images/debian.qcow2,cache=writethrough: Could not open '/Users/jpc/Library/Containers/com.utmapp.UTM/Data/Documents/Debian ARM.utm/Images/debian.qcow2': Operation not permitted

I've manually granted the UTM app "Full disk access" but it did not help.

@osy
Copy link
Contributor

osy commented Mar 21, 2021

That workaround is outdated from back when UTM was not a sandboxed app.

@sulliops
Copy link

If I move the .utm bundle to an external USB disk (APFS formatted) and create the symlink, the VM does not show in the UI at all.

I was (am) having the same problem with older versions, it's definitely not new. Would be really nice if we could just add an entry to the UTM GUI and tell it where to find the .utm.

@osy
Copy link
Contributor

osy commented Mar 22, 2021

Yeah that’s why this issue exists as a feature proposal...

@artyomxx
Copy link

It's a shame that nowadays this kind of functionality is not being built-in into trendy VM software from the very start. It's essential.

@osy
Copy link
Contributor

osy commented Jun 16, 2021

It's a shame that nowadays this kind of functionality is not being built-in into trendy VM software from the very start. It's essential.

It’s a shame Apple’s apis don’t allow for this to be done easily. It’s open source though why don’t you give it a shot and send a PR once it’s done. We’d all be very thankful 😉

@thebitstick
Copy link

It's a shame that nowadays this kind of functionality is not being built-in into trendy VM software from the very start. It's essential.

Since when did UTM have a price tag.
Such entitlement 😔

@fulldecent
Copy link
Contributor

Here are some behavior changes that could be in-scope for this issue:

  • On first run, ask for permission to open/create ~/Documents/UTM (not a hidden folder container)
    • By default, create all new .utm files there
  • When double clicking a .utm file:
    • (optional) ask if this file should be moved into the ~/Documents/UTM folder
    • open that file in-place
    • add it to the side bar of VMs
    • highlight that VM
  • Allow drag-and-drop of any .utm file anywhere into the side bar of VMs
  • In the main UTM window, on the detail (right) side, below Status / Architecture / etc., show a new line: "Location: " with the .utm file location
  • On the left side of the main window, change Right click > Delete to be "Delete..." indicating that the action is not immediate (separate issue Add an ellipsis to menu item that require interaction #2667)
  • After clicking Delete..., update confirmation dialog to have three options
    • Delete data file (4GB) and remove from list [[RED]]
    • Only remove from list
    • Cancel

Discussion:

Personally I think of .utm files as files that I control. I can torrent them, share them, back them up, delete them, copy them somewhere. And since they are big, I can run them in-place from an external drive. Also, I assume VMs specifically cause a lot or wear on a hard disk so I assume keeping them off a soldered-on main drive is a good idea.

Currently, UTM stores all files in a hidden folder that can be many many gigabytes. This is too easy to forget about. I feel that only preferences and minor configuration items should be stored in hidden folders.

@prr643
Copy link

prr643 commented Aug 7, 2021

I'm sorry, but I see the inability to store utm files easily where ever you like, especially to external devices, as a huge flaw in the UTM software. This is especially true for software designed for modern Macs, where small internal SSD sizes are unfortunately common on most non-custom ordered machines. The ability to easily run a VM from an external device is not only needed, but in my opinion essential for virtualization software for a Mac.

@kevingoh
Copy link

I have just experimented the solution as suggested by this post and it worked (i.e. I could run .utm from my external drive)

@harperjohn
Copy link

harperjohn commented Sep 22, 2021

Thanks @kevingoh !

I (eventually) got this to work too!!

My initial struggle was that I tried to mount the sparse image to the "UTM" (which is actually "com.utmapp.UTM") and then UTM just seemed to ignore the link and create a new "UTM" folder.

I then mounted a sparseimage to the "Data" sub-folder, and this seemed to work fine!

Did you got it to work at the UTM folder level ? (I do think it is cleaner/neater to link at the UTM level... but I am also quite fine with my link at the "Data" folder level, as it seems to be working fine)

@osy osy modified the milestones: v2.3, v3.1 Oct 9, 2021
@xros
Copy link

xros commented Oct 29, 2021

I have just experimented the solution as suggested by this post and it worked (i.e. I could run .utm from my external drive)

Thanks. This is current method to run .utm vms from external drive. It works. I create a shell script to run it automatically.

echo "[+] ----- Mounting to /Users/alex/Library/Containers/com.utmapp.UTM/Data/Documents ----"
hdiutil attach /Volumes/sn550-1t/vms_parallels_arm64/utm_vms/sparse_image_as_virtual_disk_for_utm.sparseimage -mountpoint /Users/alex/Library/Containers/com.utmapp.UTM/Data/Documents
echo "[+] ----- Finished mounting ---"

It's not perfect but it works.

@mertsaner
Copy link

Hi,
I try to run UTM via an external hard drive, when I try allies on the hard drive and try to import it to UTM, it copies the original .utm file to document, however, I would like it to run on an External drive, not in the Macbook. How can I do that?
Thanks for any help,

@mertsaner
Copy link

Workaround: quit UTM, move your .utm bundles elsewhere, and the symlink them to your Documents folder. This will need to be done manually for every VM you create, but at least you don't use up your iCloud storage.

It did not work with me, can you describe how you do that? It does not appear my UTM when I make a symlink of the UTM file that is on the external disk.

@mertsaner
Copy link

I have just experimented the solution as suggested by this post and it worked (i.e. I could run .utm from my external drive)

Thanks. This is current method to run .utm vms from external drive. It works. I create a shell script to run it automatically.

echo "[+] ----- Mounting to /Users/alex/Library/Containers/com.utmapp.UTM/Data/Documents ----"
hdiutil attach /Volumes/sn550-1t/vms_parallels_arm64/utm_vms/sparse_image_as_virtual_disk_for_utm.sparseimage -mountpoint /Users/alex/Library/Containers/com.utmapp.UTM/Data/Documents
echo "[+] ----- Finished mounting ---"

It's not perfect but it works.

When I try this I got the error “com.utmapp.UTM” couldn’t be", any suggestions?

@Dominik-1980
Copy link

Would be great if there is any solution, because my Mac Mini M1 only has 256GB internal SSD...

@mertsaner
Copy link

mertsaner commented Dec 8, 2021

The link above worked for me afterwards (after spending time and figuring out what is going on exactly) , so it is doable for sure, but M1 does not support Ubuntu 18.04 natively so it is not practical for some use cases but 20.04 works like a charm.

@xros
Copy link

xros commented Jan 15, 2022

I have just experimented the solution as suggested by this post and it worked (i.e. I could run .utm from my external drive)

Thanks. This is current method to run .utm vms from external drive. It works. I create a shell script to run it automatically.

echo "[+] ----- Mounting to /Users/alex/Library/Containers/com.utmapp.UTM/Data/Documents ----"
hdiutil attach /Volumes/sn550-1t/vms_parallels_arm64/utm_vms/sparse_image_as_virtual_disk_for_utm.sparseimage -mountpoint /Users/alex/Library/Containers/com.utmapp.UTM/Data/Documents
echo "[+] ----- Finished mounting ---"

It's not perfect but it works.

When I try this I got the error “com.utmapp.UTM” couldn’t be", any suggestions?

Firstly you need to make a file such as sparse_image_as_virtual_disk_for_utm.sparseimage from this post
Later, you need to modify the codes I wrote. Change it to your own username on MacOS.

/Users/alex/Library/Containers/com.utmapp.UTM/Data/Documents to /Users/your_user_name/Library/Containers/com.utmapp.UTM/Data/Documents

Don't forget to change your folder's path, where you want to be mounted to on your external SSD. E.g. I was using a SN550 1T hard drive.

@yasinusta
Copy link

Can someone make a video about it so we can run it on our external drive? I am getting a errors and I probably doing something wrong. No idea how to run shell script on my mac.

@Madhawa97
Copy link

Madhawa97 commented Jan 28, 2022

@xros So the hdiutil attach command needs to be run, each time I wanna attach the sparse image. right? Assuming Yes, I created an alias in .zshrc
works as expected. Thank you.

@xros
Copy link

xros commented Jan 29, 2022

@xros So the hdiutil attach command needs to be run, each time I wanna attach the sparse image. right? Assuming Yes, I created a alias in .zshrc works as expected. Thank you.

Yes currently you have to run it everytime when you want to use UTM.

I glad that helps you. 😉

@adespoton
Copy link

For those of you writing external scripts to mount images for use in UTM...
...why not just brew install qemu and copy the command-line flags from UTM to run the same configuration from a .sh file? Then you get full access to the monitor as well, and can access stuff that is unavailable inside a sandbox. By default it doesn't come with SPICE, so you'd also have to adjust your brew config to set the SPICE flags if you want that integration.

To me the point of UTM is that it's something contained that will be allowed on the app store and provides simple, visual "yes this just works" options for easy use. So any solutions provided should be things that work with sandboxed apps.

Maybe it's just a case of entitlements being set correctly, so there's access to the ~/Documents folder?

@ipriyam26
Copy link

@adespoton can you please give some steps on how to do it exactly

@adespoton
Copy link

@ipriyam26 do which exactly? Run QEMU without UTM? Or how to add entitlements to UTM so that it can use the ~/Documents/ folder instead of the ~/Library/Containers/ folder?

For the first, take the UTM QEMU export string and strip out all the SPICE components, install homebrew on your Mac, and run brew install qemu. Then from the terminal (or a .sh or .command file) run the string UTM generated, but point the drive image at whatever location you want instead of the copy in the UTM container folder.

If you want SPICE integration, you'll have to go to the QEMU website, download QEMU, go to the SPICE website, download the SPICE source, and compile QEMU with the SPICE flags set. If there's already a keg set up on homebrew for SPICE-enabled QEMU, I don't know about it.

@osy
Copy link
Contributor

osy commented Feb 13, 2022

Implemented as part of #132

@osy osy closed this as completed Feb 13, 2022
@gitKearney
Copy link

I figured I'd post what I consider potato head instructions, cause creating a sparse image wasn't easy

STEP 1 - create the sparse image

Open Disk Utility. Create a new Blank Image

Save As: Documents
Name: Documents
Size 32 GB
Image Format: Sparse Disk Image

STEP 2

QUIT UTM

STEP 3 -

EJECT THE SPARSE IMAGE FROM DISK UTILITY

STEP 3

MOUNT THAT SPARSE IMAGE

  • rename the existing UTM/Data/Documents directory
  • hdiutil attach /Volumes/MY_EXTERNAL_SSD/Documents.sparseimage -mountpoint ~/Library/Containers/com.utmapp.UTM/Data/Documents
  • move the existing Public and .utm files to the directory ~/Library/Containers/com.utmapp.UTM/Data/Documents

STEP 4 - PROFIT!

now you should be able to start UTM and your VMs should show up. Be mindful, they are a bit slower but not by much

@xros
Copy link

xros commented Feb 2, 2023

I figured I'd post what I consider potato head instructions, cause creating a sparse image wasn't easy

STEP 1 - create the sparse image

Open Disk Utility. Create a new Blank Image

Save As: Documents Name: Documents Size 32 GB Image Format: Sparse Disk Image

STEP 2

QUIT UTM

STEP 3 -

EJECT THE SPARSE IMAGE FROM DISK UTILITY

STEP 3

MOUNT THAT SPARSE IMAGE

  • rename the existing UTM/Data/Documents directory
  • hdiutil attach /Volumes/MY_EXTERNAL_SSD/Documents.sparseimage -mountpoint ~/Library/Containers/com.utmapp.UTM/Data/Documents
  • move the existing Public and .utm files to the directory ~/Library/Containers/com.utmapp.UTM/Data/Documents

STEP 4 - PROFIT!

now you should be able to start UTM and your VMs should show up. Be mindful, they are a bit slower but not by much

Exactly! Sorry I didn't write it clearly in my last post.

Hope UTM can really consider to customize the file path of your VMs once AGAIN!

@kingson87
Copy link

kingson87 commented Feb 7, 2023

hdiutil attach /Volumes/SSD/UTM.sparseimage -mountpoint ~/Library/Containers/com.utmapp.UTM/

This command worked for me on M1 mac and copying the data folder as a whole

@anuprshetty
Copy link

Hey guys,
I got a simple straight forward solution to this.

I am giving the steps from the beginning:

install UTM on Mac
create required VMs in the UTM following the standard procedures.
--> at this point, created VMs complete data is stored at location --> ~/Library/Containers/com.utmapp.UTM/Data/Documents/
--> for example, in my case, i have created kali and parrot VMs. So data location of these VMs will be,
--> i) ~/Library/Containers/com.utmapp.UTM/Data/Documents/kali.utm (contains OS + data)
--> ii) ~/Library/Containers/com.utmapp.UTM/Data/Documents/parrot.utm (contains OS + data)
--> So ideally you just need to move above 2 utm files to your desired destination location. But don't do it manually. Let UTM software do the job. See next step.
Insert your external harddrive to Mac.
Now open your UTM dashboard(App). In the left side you see all the VMs.
Right click on each VM, then select "move" option. After that select the destination location as your external harddrive location. Then click "confirm".
Now you have moved your VM to your destination location. Also VM data at location ~/Library/Containers/com.utmapp.UTM/Data/Documents/ is removed. Repeat the same for all the VMs.
NOTE: UTM software simply needs an .utm file. So you can manually keep that file anywhere you want. Open UTM software dashboard. Then open finder and double click on the file which you have copied to open in UTM software. That's it.

Cons: You have to do this manually for each VM you create. Anyways we achieved what we want. Peace :)

@gitKearney
Copy link

@anuprshetty this must be new functionality that osy got working. thanks for posting. I'll try this out

@malhal
Copy link

malhal commented Sep 8, 2023

I tried the right-click on the VM and move to external SSD but the app just hangs and uses 100% CPU so I killed it. They need to get the copy in a background thread and show progress in the UI.

@cw1nte
Copy link

cw1nte commented Aug 10, 2024

Move (=copy) sparse images can get super-slow, like really days I hear. Has anyone suffered that? I've had it slow but not THAT slow, mostly I have had success without using the copy routines coded within UTM [ I was OK moving uVM folders using Finder]. I believe someone (osy?) had maybe forked in UTM code to fix the slow copying.

Also finding it very sketchy looking at file sizes and their exact nature: is it macOS sparse, clone (?which may induce CoW behaviour on top of qcow2 format which again uses CoW). Often the package (eg reveal package contents) in macOS may be much larger or smaller than the apparent size of the files within it. Not enough time to really study this issue, yet...

I also suspect Finder moves between drives may end up with something UTM will find/treat/result as a Clone (in macSO view) - which AFAIK should not be the case (at least on initial copy). YMMV I'm interested to hear...

malhal is right about the copying issue, I run iostat in terminal to watch disc activity when UTM does any disc thing - this allows me to see how it progresses, size and number of transfers, when it ends, how long it took...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request macOS macOS issues
Projects
None yet
Development

No branches or pull requests