Vagrant Virtual Machines on M1 Arm Macs

What’s the issue?

What are the options ?

There are various ways to go; using an emulator like UTM, or VMWare’s tech preview for Mac M1, or even set up docker to emulate x86 images and launch it with vagrant.

Setting up VMWare

1. Download VMWare tech preview

First off you need the latest tech preview of VMWare Fusion: https://customerconnect.vmware.com/downloads/get-download?downloadGroup=FUS-PUBTP-2021H1

2. Remove / Rename the old VMWare app (if you have it)

Vagrant looks for the VMWare app by name — “VMware Fusion”, and the Tech Preview is called “VMware Fusion Tech Preview”.

3. Create a Alias / Sim link to the Tech Preview

Then create a sim link in the applications folder called “VMWare Fusion” pointing to “VMware Fusion Tech Preview”.

ln -s "/Applications/VMware Fusion Tech Preview.app" "/Applications/VMware Fusion.app"

Grab a ARM Linux distro

Next you need an ARM based linux base box for vagrant , preferably one that has been created for use with VMWare.

Configure Vagrant

The vagrant file will pretty much stay the same, but there are a few tweaks to make.

1. Update the config.vm.box property

Update config.vm.box to point to the new ARM box.

2. Update any other OS specific settings

As we had come from Centos to Ubuntu, a few of the config.vm.synced_folder mount options had to be tweaked, mainly adding the allow_other option.

3. Update the config.vm.provider settings

The core part to change is the config.vm.provider settings.

vmware.vmx['ethernet0.pcislotnumber']

When booting the box for the fist time, Vagrant may warn you about the vmware.vmx['ethernet0.pcislotnumber'] setting. It maps PCI slots between the host and the guest — but thankfully Vagrant will tell you want to set it to!

WARNING: The VMX file for this box contains a setting that is automatically overwritten by Vagrant
WARNING: when started. Vagrant will stop overwriting this setting in an upcoming release which may
WARNING: prevent proper networking setup. Below is the detected VMX setting:
WARNING:
WARNING: ethernet0.pcislotnumber = "33"
WARNING:
WARNING: If networking fails to properly configure, it may require this VMX setting. It can be manually
WARNING: applied via the Vagrantfile:
WARNING:
WARNING: Vagrant.configure(2) do |config|
WARNING: config.vm.provider :vmware_desktop do |vmware|
WARNING: vmware.vmx["ethernet0.pcislotnumber"] = "33"
WARNING: end
WARNING: end
WARNING:
WARNING: For more information: https://www.vagrantup.com/docs/vmware/boxes.html#vmx-allowlisting

vmware.allowlist_verified

Even when you have set the pcislotnumber you will still be warned about it each time you do a vagrant up . To suppress this message you can set vmware.allowlist_verified to true

vmware.gui

I did find one issue, when launching with vagrant up it hangs waiting for the server to start, before it SSH’s into it to provision the box.

Bringing machine 'default' up with 'vmware_desktop' provider...
==> default: Checking if box 'bytesguy/ubuntu-server-20.04-arm64' version '1.0.0' is up to date...
==> default: Verifying vmnet devices are healthy...
==> default: Preparing network adapters...
==> default: Starting the VMware VM...
==> default: Waiting for the VM to receive an address...

config.vm.provider

The final config looks something like this

config.vm.provider :vmware_desktop do |vmware| vmware.vmx["ethernet0.pcislotnumber"] = "33"
vmware.vmx["memsize"] = "4096"
vmware.vmx["numvcpus"] = "2"
vmware.gui = true
vmware.allowlist_verified = true
end

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store