[How To] Run Manjaro Linux in a VM on MacOS using Virtualization.framework

How to run (Manjaro) Linux in a VM on MacOS, using the Virtualization.framework that comes with MacOS 11+.

Read the README.md from vftool (link below) carefully and understand the limitations of this approach! On the positive side this gives you a Linux VM on your Mac with tiny overhead. All you need is a disk image and a small tool like vftool or SimpleVM. (Free and Open Source, no dependencies.) Virtualization.framework uses paravirtualization with VirtIO. It does not emulate a CPU. The VM runs native as a user space process. Therefore on an Apple silicon Mac you can run arm64 / aarch64 Linux only, and on an Intel Mac x86_64 / amd64 Linux only.

This example uses an Apple Silicon i.e. aarch64 / arm64 based Mac. You can do this the same way with an Intel based Mac. You just need different images based on the x86_64 architecture.

This example uses Manjaro Linux. You can use any other distribution as you wish. The kernel needs to have the VirtIO drivers enabled. Especially CONFIG_VIRTIO_CONSOLE=y. Debian falied on me for this reason.

Now, how to do it:

Get, compile, install vftool from

It may be avaliable via homebrew or macpots the time you read this.
Alternative:

$ mkdir ~/ManjaroVM
$ cd ~/ManjaroVM

Download a SD card image from

e.g. Manjaro-ARM-minimal-generic-22.04.img.xz

unzip:
$ gzip -d Manjaro-ARM-minimal-generic-22.04.img.xz

Enlarge disk image, optional:
$ dd if=/dev/zero bs=1m count=1024 >> Manjaro-ARM-minimal-generic-22.04.img

Mount disk image:
$ hdiutil attach Manjaro-ARM-minimal-generic-22.04.img
Note on which device it gets attached. E.g. /dev/disk4
and which partition is “Linux Filesystem”.

Copy kernel and initrd from the disk image to your VM directory:

$ cp /Volumes/BOOT_MNJRO/initramfs-linux.img .
$ cp /Volumes/BOOT_MNJRO/Image kernel-linux.img

Detach disk image:
$ hdiutil detach disk4
Use device from attachment above.

Start the VM:

$ vftool -t 1 -a "console=hvc0 root=/dev/vda2" \
	-k ~/ManjaroVM/kernel-linux.img \
	-i ~/ManjaroVM/initramfs-linux.img \
	-d ~/ManjaroVM/Manjaro-ARM-minimal-generic-22.04.img

Note in the output of vftool the tty the console gets attached to.
Depending on the partition layout of the disk image you may need to change the root device. You get a clue about the partition layout when you “hdiutil attach” the image. E.g.:
/dev/disk4s2 Linux Filesystem
maps to /dev/vda2.

Connect to the VM console in an other terminal:
$ screen /dev/ttys015
Now the VM should boot.

Login as root and complete install.
Rebooting does not work. Change to vftool and stop it with CTRL-C.
Restart VM and enjoy. :slight_smile:

If you want X11 for your VM use VNC or RDP. I have good experiences with the M$ RDP client from the Apple AppStore connecting to (non virtual) Linux machines running xrdp / xorgxrdp. Note: Manjaro ARM does not come with xorgxrdp out of the box. It can be enabled with some fiddling, but that is an other story…

1 Like

Addendum:

There is this fork of vftool:

It adds the command line option -r to set a fixed Ethernet MAC address. With a fixed MAC your VM gets the same IP at every boot. Without a fixed MAC a random MAC is chosen and thus the IP of the VM changes every time vftool starts.