Published on 12 January 2023 by Andrew Owen (4 minutes)
I’ve mentioned UTM before. It’s a nice wrapper for QEMU that enables you to create ARM virtual machines and emulate non-ARM machines on macOS. It’s a free download from the website, or you can get it in the app store. But one of the features I’ve been looking forward to is being able to use Rosetta to do X64 to ARM64 instruction translation, which is supported in the latest version of UTM on macOS Ventura. I was hoping to be able to install Intel VMs using Rosetta, but for that you still have to use QEMU. What you can do is install a Debian ARM VM, enable Rosetta, and then run X64 Debian packages on that VM. This can be useful if there’s a particular package you need that doesn’t have a native ARM build. Thus far I’ve only got it to run packages, and not individual Intel binaries. There is also a big caveat:
There is a bug present in Linux virtual machines on Ventura and the base M1 chip that causes the virtual machine to randomly kernel panic and freeze. Unfortunately, this means that base M1 users should avoid Apple Virtualization backend until Apple or Linux maintainers provide a fix.
I’m running on an M1 Pro, and that seems to work well. After you’ve installed UTM you’ll need the Debian Net Installer. You’ll also need to install Rosetta.
$ set USERNAME=`whoami`
$ su -p
# /usr/sbin/usermod -aG sudo $USERNAME
After you enable sudo for the default user, you must restart the VM for the change to take effect.
sudo apt install spice-vdagent
.sudo apt install binfmt-support
.sudo mkdir /media/rosetta
.sudo mount -t virtiofs rosetta /media/rosetta
./etc/fstab
: rosetta /media/rosetta virtiofs ro,nofail 0 0
.sudo / usr / sbin / update - binfmts--install rosetta / media / rosetta / rosetta \
--magic "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00" \
--mask "\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \
--credentials yes--preserve no--fix - binary yes
The magic parameter describes the first 20 bytes of the ELF header for X64 binaries. The Linux kernel performs a bitwise logical AND with the first 20 bytes of any binary you try to run with the mask value. If there’s a match, it uses the registered handler to interpret the binary. Otherwise, it reports an error.
7. Enable X64 packages:
sudo dpkg --add-architecture amd64
sudo apt update
Now you can now install and run any X64 package in the Debian repository with sudo apt install packagename:amd64
.
One such package is WINE, which will enable you to run some 64-bit Windows binaries. But you’ll also need to install WINE32 to get it to launch. I’m not sure if Rosetta can be persuaded to run 32-bit binaries as well. I’ll have to do some further investigation. You’ll also need to enable X86 packages:
sudo dpkg --add-architecture i386
sudo apt update
Then you can install WINE with:
sudo apt install wine64:amd64
sudo apt install wine32:i386
So far, I’ve only got the built-in file explorer working (launch with wine64 explorer
). If I get 32-bit apps working I’ll write a new article on it.