Build VMs on Mac M1/M2 with Vagrant & VMware Fusion

Build VMs on Mac M1/M2 with Vagrant

MAC silicon M1/M2 chips use ARM architecture which is different from x86 used by Intel processors.

The only solution to run virtual machines on mac silicon is using VMware fusion and Vagrant. I have tried Virtualbox and it doesnt work well and you dont find good ARM based vagrant boxes that has support for Virtual box.

Virtual box + Vagrant works great on my MAC intel based system. But for my MAC silicon, I use VMware Fusion + vagrant and it works great.

In this blog I will walk you through step by step process of setting up VMware fusion and vagrant to create VMs.

Prerequisites

Following are the prerequisites for this setup.

  1. macOS (M1/M2) with admin access.
  2. Homebrew

Setting Up VMware Fusion

VMware Fusion can be used for free with the personal free licence. Follow the steps given below to setup VMware Fusion.

Step 1: Register for the VMWare Customer Connect Account. You need this account to download softwares from Vmware.

Step 2: Download and install VMware Fusion

When asked for licence, choose the personal free licence and get it from the licence page.

VMware Fusion Perosnal free licence

Follow the installation wizard. All are self explanatory steps.

You can cancel the final installation method as we will be managing the VMs using Vagrant

cancel the final installation for VMware fusion to use vagrant

Vagrant is a open source wrapper utiltiy that interacts with VMWare Fusion to create and manager virtual machines.

Follows the steps to install vagrant and VMWare related vagrant utilties.

Step 1: Install vagrant from the Downloads page

If you have homebrew, you can install it using the following commands.

brew tap hashicorp/tap
brew install hashicorp/tap/hashicorp-vagrant

Step 2: Install Vagrant VMware Utility

Download and install the VMware Vagrant Utilty for MAC

MAC Vagrant VMware Utility

Step 3: Install VMware Provide plugin using the vagrant command.

sudo vagrant plugin install vagrant-vmware-desktop

Step 4: Restart Your System

Once all the above mentioned installations are done, restart your MAC.

If you dont restart your MAC, you will get the following error.

Vagrant failed to create a new VMware networking device. The following
error message was generated while attempting to create a new device:

  Failed to enable device

Please resolve any problems reported in the error message above and
try again.

Building a VM with Vagrant

To test the setup, you can clone the Kubernetes certification repo where we have the Vagrantfile to deploy three VMs.

git clone https://github.com/techiescamp/kubernetes-certification-guide.git

cd in the the mac silicon folder. It has a Vagrantfile with bento/ubuntu-22.04 vargantbox for arm architecture that deploys three VM’s. You can modify the VM details in the settings.yaml file present in the folder.

cd lab-setup/mac-silicon

Now, bring up the VMs using vagrant.

Important Note: Ensure you use sudo with the command. Without sudo, it wont work.

sudo vagrant up

It should bring up three VMs.

Using the VM

To login to specific VM, use the node name with ssh.

To get the node names, execute,

$ sudo vagrant status

Current machine states:

controlplane              running (vmware_fusion)
node01                    running (vmware_fusion)
node02                    running (vmware_fusion)

Use the machine names to ssh. For example,

sudo vagrant ssh controlplane

Top stop the VMs,

sudo vagrant halt

To bring up the VMs again, run

sudo vagrant up

Conclusion

Vagrant is a great utility for running VMs locally on MAC silicon.

You can setup multi node applications, kubeadm kubernetes clusters etc that closely replicates the production systems.

If you face any errors during the setup, drop a comment. We will look at it.

5 comments
  1. Hi! Thank you for the article.
    I have a Mac M1. I followed all the steps and everything seems to be OK. However, after executing `vagrant up` the VMs does not seem to run. I mean they remain in `not running (vmware_fusion)` state.
    Do you have any idea or suggestion?
    Thanks in advance!

  2. I had to create the private_network manually. Wasn’t able to get it to create via the sudo vagrant up command. If this is expected behavior, worth adding to the guide on this wiki and GitHub documentation.

  3. Hi Bibin,

    I followed the step and i can see the VMs launched. But i could see the VM names in the VMware fusion. It seems empty and i did restart app but no luck.
    Thanks

    1. Hi Sathish,

      The VMS will not be listed on fusion. You can use the vagrant command to ssh in to the VM and use the VMs IP address to access appliations.

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like