Installing OpenWrt on m1 mac apple silicon virtualization software

Hi,

Is there an image of OpenWrt that can install on the new m1 mac through parallels, UTM or the vmware fusion preview for m1 mac?

No, that would be up to you to develop. The virtualization layer abstracting the hardware (to some extent) will make that easier than potential bare iron support, but it's still not going to be fun.

Hi there, it's called armvirt and it's here: https://downloads.openwrt.org/releases/22.03.2/targets/armvirt/64/

Hi.
I tried to make it work with parallels and utm, but I didn't succeed.
Do you have any hints which settings and which programm you used?

Hi @pbengert, I have OpenWrt running on an M1 under UTM.

Are there any particular questions you have? I don't recall precisely what challenges I had when I set it up but I do recall that there were a few hurdles I overcame. Happy to look at my config and compare notes and help you set it up.

1 Like

Hi, thanks for answering!
Here are more specific questions:

  1. Which OpenWRT Image did you download? These are the images available for 22.03.2 at the moment:
openwrt-22.03.2-armvirt-64-Image
openwrt-22.03.2-armvirt-64-Image-initramfs
openwrt-22.03.2-armvirt-64-default-rootfs.tar.gz
openwrt-22.03.2-armvirt-64-rootfs-ext4.img.gz
openwrt-22.03.2-armvirt-64-rootfs-squashfs.img.gz
openwrt-22.03.2-armvirt-64-rootfs.cpio.gz
  1. As there is no OpenWRT installer we have to attach the downloaded image to the VM. How did you attach it? Maybe you could post a screenshot of your drive mapping (I tried using drive-image and virtio as the Interface, I tried serveral others, but no luck)

  2. Do you have any special setting in System Tab? (I have ARM64, QEMU 7.2 ARM Virtual Machine)
    Or in the QEMU settings (is UEFI boot enabled or not)?

If possible, maybe you could post a screenshot of your System, QEMU and Drive Tab in UTM.

If I use UEFI I drop into the UEFI shell but can not find a drive, if I disable it I get "Guest has not initalized the display yet".

Thanks a lot! Your help is much appreciated!

I recommend using the current Image and rootfs-squashfs releases. At the time of this writing that would be openwrt-22.03.5-armvirt-64-Image and openwrt-22.03.5-armvirt-64-rootfs-squashfs.img.gz.

The rootfs image needs to be decompressed (gunzip). UTM will convert the raw .img file to a .qcow2 itself.

You will need to attach two "Drives", one for the kernel and one for the rootfs:


In order for the kernel to locate the rootfs, the QEMU command line needs β€œ-append root=/dev/vda” which should be specified as two separate lines under the QEMU section of the virtual machine configuration in UTM. (scroll down in that window to see this)

For output, serial console is what worked for me. I removed the unused display device to reduce any confusion and added a new β€œSerial” device. The UI for this has changed from prior versions of UTM, it used to be a simple checkbox but in recent versions it's a device proper.

Not strictly necessary but as you can see, I added additional Network devices as well. I'm using virtio-net-pci for those.

ARM64, QEMU 7.2 ARM Virtual Machine is the correct profile. UTM will create a copy of ("alias of ...") it after you modify any settings iirc.

Here are screenshots of the "System" and the top of my "QEMU" sections. My QEMU command is default except for the kernel command line append I mentioned above:


Thank you! No problem.

Let me know if you have any other questions.

2 Likes

Wonder what's the power consumption of a M1/Mx apple router that only has the virtualization running?

I'm not asking you to bust out the power meter...just a wonder out loud thing....would it be more than 2W or less than 2W? Why I settle on 2W, my frame of reference is--> I saw some comparison of a m1 notebook watching youtube had like 4W comparing with mobile intel 12xx with 10W, mobile ryzens 5xx with 8W.

Oh great. Worked liked a charm.
Thank you very much.

Just for making this thread more useful for other people. I just found out that there is even a section on the OpenWRT wiki for running it on ARM Macs using plain qemu from the command line that I link here.

This command will run OpenWRT in QEMU from the terminal. But I was only able to "translate" it to UTM settings using your post.

qemu-system-aarch64 -m 1024 -smp 2 -cpu host -M virt,highmem=off \
-nographic \
-accel hvf \
-kernel openwrt-22.03.5-armvirt-64-Image \
-drive file=openwrt-22.03.5-armvirt-64-rootfs-squashfs.img,format=raw,if=virtio \
-append root=/dev/vda \
-device virtio-net,netdev=net0 -netdev user,id=net0,net=192.168.1.0/24,hostfwd=tcp:127.0.0.1:1122-192.168.1.1:22 \
-device virtio-net,netdev=net1 -netdev user,id=net1,net=192.0.2.0/24
1 Like

Not to be overly pedantic but here's the full command that UTM runs for me in case it could help someone trying to run this without UTM directly via QEMU installed via Homebrew or MacPorts:

qemu-system-aarch64 \
  -L /Applications/UTM.app/Contents/Resources/qemu \
  -S \
  -spice "unix=on,addr=/Users/jenders/Library/Group Containers/WDNLXAD4W8.com.utmapp.UTM/187A8177-4A59-4E5D-BB9A-190735D35401.spice,disable-ticketing=on,image-compression=off,playback-compression=off,streaming-video=off,gl=off" \
  -chardev spiceport,id=org.qemu.monitor.qmp,name=org.qemu.monitor.qmp.0 \
  -mon chardev=org.qemu.monitor.qmp,mode=control \
  -nodefaults \
  -vga none \
  -device virtio-net-pci,mac=F6:9D:AD:6D:3A:0D,netdev=net0 \
  -netdev vmnet-shared,id=net0 \
  -device virtio-net-pci,mac=B2:2E:CD:9E:88:B8,netdev=net1 \
  -netdev vmnet-shared,id=net1 \
  -nographic \
  -chardev spiceport,id=term0,name=com.utmapp.terminal.0 \
  -serial chardev:term0 \
  -cpu host \
  -smp cpus=2,sockets=1,cores=2,threads=1 \
  -machine virt \
  -accel hvf \
  -m 512 \
  -device nec-usb-xhci,id=usb-bus \
  -device usb-tablet,bus=usb-bus.0 \
  -device usb-mouse,bus=usb-bus.0 \
  -device usb-kbd,bus=usb-bus.0 \
  -device qemu-xhci,id=usb-controller-0 \
  -chardev spicevmc,name=usbredir,id=usbredirchardev0 \
  -device usb-redir,chardev=usbredirchardev0,id=usbredirdev0,bus=usb-controller-0.0 \
  -chardev spicevmc,name=usbredir,id=usbredirchardev1 \
  -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1,bus=usb-controller-0.0 \
  -chardev spicevmc,name=usbredir,id=usbredirchardev2 \
  -device usb-redir,chardev=usbredirchardev2,id=usbredirdev2,bus=usb-controller-0.0 \
  -kernel "/Users/jenders/Library/Containers/com.utmapp.UTM/Data/Documents/ openwrt-22.03.2-armvirt-64.utm/Data/openwrt-22.03.2-armvirt-64-Image" \
  -device virtio-blk-pci,drive=driveABC64356-080D-46DD-9883-E35516B8C6F1,bootindex=0 -drive "if=none,media=disk,id=driveABC64356-080D-46DD-9883-E35516B8C6F1,file=/Users/jenders/Library/Containers/com.utmapp.UTM/Data/Documents/ openwrt-22.03.2-armvirt-64.utm/Data/openwrt-22.03.2-armvirt-64-rootfs-squashfs.qcow2,discard=unmap,detect-zeroes=unmap" \
  -name " openwrt-22.03.2-armvirt-64" \
  -uuid 187A8177-4A59-4E5D-BB9A-190735D35401 \
  -append root=/dev/vda

anybody able to install openwrt in vmware fusion in m1 mac?
can't get the disk to boot

Hello and thanks for your advice! Unfortunately despite having done everything you said I can't open openwrt correctly on mac m1... Would it be possible to have a step by step guide on how to do it? Thanks again

I wrote up my guide to OpenWrt on UTM on Apple Silicon on the wiki: https://openwrt.org/docs/guide-user/virtualization/utm

1 Like

I just wrote up my experience in https://openwrt.org/docs/guide-user/virtualization/fusion .

I'll note that I find UTM easier to use in this case, and likely faster--it supports VirtIO for the network interfaces, whereas Fusion does not.

Just walked through this guide and it works great. Thank you!