Development on Apple Silicon with UTM
rkiselenko.dev
rkiselenko.dev
I guess part of why I'm asking is because I've set up virtual machines in UTM on Apple Silicon before, and I never had to go through all of this just to get Linux installed and configured. The post makes me wonder if there's something I'm maybe missing, but it doesn't give any explanation for me to be able to figure out if that's the case. Maybe the post is meant more just as a checklist for the person that wrote it, for their own reference? But the way the post reads doesn't quite sound that way.
Hmm... that's all coming out sounding more critical than I mean to. I just want more info and I am curious about the approach.
Also, you don't need all 4 Linux images, just the one you want to run as your guest OS. Emulation / virtualization depends on the guest OS CPU architecture.
The easiest way is to just choose from the UTM gallery. But I wanted Fedora 41, not 38 which is the latest in the gallery.
I don’t understand why anyone would go to the route of emulation in 2025, but if someone wants to run an x86_64 image with UTM, well that’s the only route – I’d suggest just going to an aarch64 image. Things were a bit more rough back in 2020, but stuff got much better and I don’t remember any compatibility problems these days.
[0] https://cloudinit.readthedocs.io/en/latest/reference/datasou...
Afaik UTM uses Qemu under the hood, but provides a nice UI on top for the basic use cases. It also has a library of prepared images, so that your VM is a few clicks away from intention to have one.
It can also modify the VM, resize storage after creation etc.
Of course all of it can be done with QEMU alone, but this makes it easier to deal with than remembering tons of QEMU command line arguments.
During installation UTM asks if you’re willing to use Apple virtualization rather than qemu
qemu needs to be studied a bit, UTM is fairly intuitive.
I recently decided to learn how to create VMs with bare qemu (using the command-line).
As I have an arm macbook for work, UTM helped me a ton with aarch64 virtual machines because I could enable debug log and see what qemu options/flags/switches would UTM use.
Unrelated: I have some ideas about writing a tool that aims at being a "spiritual successor" to vagrant (from hashicorp), but focused on targeting qemu rather than virtual box.
Anyone interested? Please let me know (upvote or comment)
Theoretically the entire docker workflow can be translated to VMs. In practice it is a shit show.
The biggest problem by far is building a VM image, because it consists of multiple highly irritating steps.
1. Building custom packages for the target distribution.
Since we aren't using containers, we would in principle need a full VM per application. This is not a good idea in practice. We want to avoid containers, but we still want something very much like docker images on the application level. The obvious answer is building distro specific packages.
Building distro packages is annoying, because the developer machine doesn't necessarily run the same OS as the servers. This means that building the package requires you to spin up a temporary virtual machine or a docker container. Let me tell you, it is by far easier to build your packages inside a docker container and that's why I never even bothered with the VM route, even in situations where I'm deploying VM images. There needs to be a VM based alternative to "docker build" that doesn't necessarily spit out a VM image, but rather it spits out the result of your build (e.g. packages) onto a mounted directory on the host.
If you never built your own alpine packages. Try writing an APKBUILD. It is very easy.
2. Building VM images
Now let's say we are done and just want to build our VM images. There are already distro specific tools like https://github.com/alpinelinux/alpine-make-vm-image. What you want to do is install the packages created in the first step, run a simple bash script for finishing touches and setup cloud-init for the first boot. Unlike a Dockerfile, this should be kept very simple, because the packages are already doing everything the Dockerfile is expected to do. The only thing I would overcomplicate here is directly integrating a package repository into the tool to make it effortless.
3. Running the VM
At this point everything should be quite simple. The primary use case is to run the VM image locally on a developer computer before deployment. Some quality of life features like docker style port proxying and mounting directories would be nice. This is by far the easiest part because tools like virt-manager already exist.
Last time I checked, there really isn’t any way to virtualize ARM machines on the iPad with UTM (unless you’re on a lower iOS version), and emulating x86_64 machines were slow enough (even on M4 iPads) and not really usable.
I’m on an environment where iPads are fine but equivalent MacBooks aren’t (stupid rules), and got this machine for hope that I might tinker development with iPads, but I gave up running stuff locally and just boot up an EC2 instance whenever I really want to do something. It’s a pity.
(BTW, from the article, why would anyone really emulate a Linux machine with UTM on Apple Silicon? From my experience ARM64 Linux images are really good at compatibility…)
I'm interested in an up-to-date comparison when running the VM with Rosetta 2:
colima start --vm-type=vz --vz-rosetta
⁽¹⁾ https://github.com/abiosoft/colimaEdit to add: While researching OrbStack, I found this comment in a post from 7 months ago that mirrors a lot about my experience with Colima: https://news.ycombinator.com/item?id=41424044
For example, try installing a Windows 2000 vm. It won’t even get past the initial setup screen because it runs so slowly.
My saving grace has been that Windows 11 ARM also has its own x86 translation layer, so I can still run many (but not all) 32bit windows apps. But it’s been frustrating having such a powerful machine that can’t run an x86 vm.
The issue is that of course Apple computers that are large enough to run VMs are… expensive.
So I have instead found myself using proxmox on a cheaper (by comparison) threadripper machine.
The added bonus is that xterm.js (the default LXC console viewer) works wonderfully on the iPad- Though of course you can use prompt3 for heavier duty stuff.
The other uses I have for VMs on the mac is Docker and Kubernetes, but those are solved by colima and minikube respectively.
Expensive compared to what? UTM uses Apple Virtualization Framework, which lets the guest VM only occupy as much memory as it's actually using (instead of reserving all of its available memory). This means it's viable to run a Linux VM on e.g. an 8GB RAM MacBook Air.
Maybe memory compression helps, but it doesn’t appear so to me right now.
Good question. I was speaking from memory, and all I can find when googling is this: https://docs.getutm.app/settings-apple/virtualization/#ballo...
EDIT: I recall vaguely something about it being a problem with Linux guest VMs because it aggressively uses RAM as a file system cache. So it'll just fill up RAM to the max when reading from disk, and overwrite this if it's later needed by applications.
source "utm-cloud" "this" { iso_url = "${path.root}/dev_images/al2023-kvm-2023.6.20250303.0-kernel-6.1-x86_64.xfs.gpt.qcow2" iso_checksum = "sha256:0dc2797fe19847f6c75878dd344ab478ac0657077d9a15f2907bb2df41d8c3de" vm_arch = "x86_64" cpus = 2 memory = 4096 display_nopause = true boot_nopause = true export_nopause = true skip_nat_mapping = true communicator = "ssh" ssh_clear_authorized_keys = true ssh_private_key_file = data.sshkey.this.private_key_path ssh_host = "192.168.64.100" ssh_port = 22 ssh_username = "ec2-user" shutdown_command = "echo 'packer' | sudo -S /sbin/halt -h -p" use_cd = true cd_label = "cidata" cd_content = { "meta-data" = <<EOF local-hostname: vm-hostname EOF "user-data" = <<EOF #cloud-config ssh_sftp: enabled: true password: ec2-user ssh_pwauth: True chpasswd: expire: False users: - default - name: ec2-user lock_passwd: false plain_text_passwd: ec2-user ssh_authorized_keys: - ${data.sshkey.this.public_key} EOF "network-config" = <<EOF #cloud-config version: 2 ethernets: enp0s1: # dhcp4: yes addresses: - 192.168.64.100/24 gateway4: 192.168.64.1 nameservers: addresses: - 10.0.2.2 enp0s2: dhcp4: no state: down EOF } }
There is also the issue of wanting to have your dev environment be as close to your prod environment as possible, and the vast majority of cloud-based hosting is still x86_64.
I would like to see a benchmark of these various methods…
I think the binfmt executable can be used outside of Virtualization.Framework and can even be used in an ARM VM in say Asahi but people don't because it's not easy to do but also honour system as it's not licensed for use outside of MacOS.
At the very least, I could test mock deploys from the Apple Silicon side to the x64 VM running locally (over loopback) as an extra data point
I don't actually use it for this use-case but now that I'm thinking about it, I might try, because this seems useful
Is it already possible to connect an external screen to UTM and use that as the main screen? (Multi-port Adapter or iOS, or a displaylink usb dongle on Macbook).
That would enable some great stuff. Until then, I don't think the overhead is worth it for me
Is this an unreasonable fear?
On macOS the Mac App Store has much less restrictive policies so UTM is actually approved to be installed via the Mac App Store. https://apps.apple.com/us/app/utm-virtual-machines/id1538878... Also macOS allows you to install and run applications which aren't approved by the Mac App Store. So using UTM as described in the article doesn't violate any Apple policies.
Edit: would command line linux be usable, considering it doesn't have to emulate all those pixels?
Looks like you need to install an arm distro and x86_64 binaries on top of it though. May be a lot of trouble in some cases.
"Parallels doesn't change the file associations. Parallels registers Windows apps (like Edge) for macOS in case users want to open them/files using macOS interface. macOS then decides what apps to use for this or that file type or protocol. Based on our testing if there is already a file association, then a new app registered in the system doesn't change it. Tip: Parallels provides an option to disable sharing Windows apps with macOS. It is enabled by default as the vast majority of customers like it. File associations can also be changed anytime using "Get Info" in file context menu and then "Open with:" and "Change All..."."
In other words, it looks like .html files were associated to your (in-Windows) Edge, hence it booting up a VM etc. but that can easily be mitigated.