🌊

How to run x86 Linux on M1 MacBook?

2023/07/17に公開

I recently bought a new laptop with Apple M1 Max processor. It has 64 GB RAM and I really like it.

But it's a bummer that current Rosetta 2 translation layer doesn't allow me to run x86 based virtual machines. Rosetta 2 allow me to convert x86 binaries inside ARM VMs. It's pretty cool but not enought for running x86 VMs.
https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta

UTM is here to help me

So I tried options other than macOS's Virtualization framework.
It's UTM. This offers x86 guests emulation on M1 Mac by using QEMU.
https://mac.getutm.app/

https://docs.getutm.app/

UI is pretty neat. It looks like Parallels. I like it.

UTM app screenshot.

Running Rocky Linux 9

I tried to install Rocky Linux 9. It has binaly compatibility with Red Hat Enterprise Linux.
https://rockylinux.org/

But there is a bit uncertanty in the future of Rocky Linux. No one knows what'll happen.
https://rockylinux.org/news/2023-06-22-press-release/

Anyways, I downloaded the installation image. (Rocky-9.2-x86_64-minimal.iso)

Then I create a new VM config.
You need to modify 2 things from the default.

  • Change the CPU model to new one wich supports SSE4.2. (I used "Ivy Bridge".) Otherwise the installer fails with an error message like "CPU does not support x86-64-v2".
    • Also, it may be better to increase the number of cores manually.
  • Change the display hardware. (I used "VGA".) Otherwise the installer displays nothing but "Display output is not active.".

Change the CPU model.

Change the display hardware.

Then you'll see the installation dialog.

Rocky Linux installation dialog.

You'll be able to login to the shell after the installation.
Rocky Linux shell

Conclustion

QEMU is pretty slower compared to running ARM VMs with the Virtualization framework or running apps with Rosetta 2.

But it's still nice to have the x86 guest OS emulation feature on my laptop.
And UTM is pretty easy to use. It almost doesn't require anything to learn to use.

Overall, this development experience fills the gap for me as a backend developer.

Discussion