Build VMs on Apple silicon M1/M2/M3 Mac using VMware Fusion & Vagrant
First published: Tuesday, September 3, 2024 | Last updated: Tuesday, September 3, 2024Build, deploy, and automate multiple VMs parallelly on an Apple silicon (M1, M2, M3) chip-based Mac operating system using VMware Fusion and Vagrant.
Apple recently introduced the Apple silicon (M1, M2, M3) chip for its Macs and iPads, which offers a wide range of new features and advantages. However, software developers and IT professionals faced challenges when trying to deploy and manage VMs on the Mac operating system using commonly used type-2 or hosted desktop hypervisors like VirtualBox. After a long wait, a solution has finally emerged in the form of VMware Fusion. In this blog post, we will delve into the process of building, deploying, and automating multiple VMs on Macs with Apple silicon (M1, M2, M3) chips using VMware Fusion and Vagrant.
Install VMware Fusion on Apple silicon (M1, M2, M3) chip-based Mac
Typically, VMs are created using specialized software known as a hypervisor. There are two main types of hypervisor software: type-1 or bare metal hypervisors for cloud or on-premise infrastructure, and type-2 or hosted hypervisors for desktop or personal computers. Type-2 hypervisors are compatible with major desktop operating systems like Windows, Mac, and Linux. An example of a type-2 desktop hypervisor is VMware Fusion, designed specifically for Mac operating systems and compatible with both Intel and Apple silicon chips. VMware Fusion has two versions - VMware Fusion Pro and VMware Fusion Player - and more information about their differences can be found on their official websites. The following resources will guide you through the process of installing VMware Fusion on an Intel or Apple silicon (M1, M2, M3) chip-based Mac operating system.
Install and configure Git on Mac
Here are some helpful resources with detailed, step-by-step instructions for downloading, installing, and setting up Git on an Intel or Apple silicon (M1, M2, M3) chip-based Mac operating system.
Install Vagrant and its add-ons on Apple silicon (M1, M2, M3) chip-based Mac
Here are the links for the articles that offer comprehensive, detailed guidance on each step involved in downloading and installing Vagrant on an Intel or Apple silicon (M1, M2, M3) chip-based Mac operating system.
Once Vagrant has been successfully installed, the next crucial step involves the installation of the Vagrant VMware utility and subsequently the Vagrant VMware plugin. These two components play a vital role in empowering Vagrant to efficiently handle VMware Fusion, thereby streamlining the process of automating VM deployment.
Install Vagrant VMware utility
To install the Vagrant VMware utility on your Mac operating system, follow these steps carefully.
- Download the Vagrant VMware utility package.
- Execute the Vagrant VMware utility package, and proceed with Continue and Install prompts to install Vagrant VMware utility.
Install Vagrant VMware plugin
Here are the step-by-step guidelines for installing the Vagrant VMware plugin on a Mac operating system.
- Open the terminal.
- Execute the below commands in the terminal to install Vagrant VMware plugin.
# Install VMware plugin for Vagrant.
$ sudo vagrant plugin install vagrant-vmware-desktop
Setup our Linux starter-kit from GitHub
At SloopStash, we are proud to offer our own open source Linux starter-kit repository on GitHub. This repository is designed to provide robust support for a wide range of Linux-based operating systems including CentOS Linux, Ubuntu Linux, Amazon Linux, Alma Linux, Rocky Linux, and other similar equivalents. Additionally, we are committed to creating, uploading, and maintaining our VM images for these operating systems in the Vagrant registry. Our comprehensive Linux starter-kit has been meticulously curated to encompass all the essential components needed for building and running any Linux-based virtual machine. Here are the instructions for setting up our Linux starter-kit on a Mac operating system.
- Open the terminal.
- Execute the below commands in the terminal to setup our Linux starter-kit.
# Download Linux starter-kit from GitHub to local filesystem path.
$ sudo git clone https://github.com/sloopstash/kickstart-linux.git /opt/kickstart-linux
# Change ownership of Linux starter-kit directory.
$ sudo chown -R $USER /opt/kickstart-linux
Configure environment variables on Mac
Before initiating the automated deployment of a Linux VM, it is essential to carefully configure the following environment variables in your Mac terminal. These variables play a critical role in specifying the operating system (CentOS Linux, Ubuntu Linux, Amazon Linux, Alma Linux, or Rocky Linux), processor architecture (AMD64 or ARM64), edition (server or desktop), and hypervisor (VirtualBox or VMware) that will be used for the Linux VM deployment.
Supported environment variables
# Allowed values for $OS_NAME variable.
* centos-linux-7
* ubuntu-linux-18-04
* ubuntu-linux-22-04
* amazon-linux-2
* alma-linux-8
* alma-linux-9
* rocky-linux-8
* rocky-linux-9
# Allowed values for $OS_ARCHITECTURE variable.
* amd64
* arm64
# Allowed values for $OS_EDITION variable.
* server
* desktop
# Allowed values for $HYPERVISOR variable.
* virtualbox
* vmware
Set environment variables
In this section, we set environment variables for the build, deployment, and automation of the Ubuntu Linux 22.04 ARM64 server operating system using VMware Fusion hypervisor. Similarly, the environment variables can be modified to automate the VM deployment for different Linux variants and versions as mentioned above.
# Store environment variables.
$ export OS_NAME=ubuntu-linux-22-04
$ export OS_ARCHITECTURE=arm64
$ export OS_EDITION=server
$ export HYPERVISOR=vmware
Deploy and manage VMs with Vagrant automation
Vagrant provides the ability to easily create, start, stop, and remove virtual machines using straightforward commands. All the necessary configurations for the automated deployment of Linux VMs are included in our Linux starter-kit. This means that by executing the appropriate Vagrant commands, you can efficiently build, deploy, and automate Linux VMs. You can use the following commands to build, deploy, and automate Linux VMs on a Mac operating system using Vagrant.
If you encounter any issues while deploying Linux VMs, please raise an issue in our Linux starter-kit on GitHub.
- Open the terminal.
- Execute the below commands in the terminal to build, deploy, and automate Linux VMs.
# Switch to Linux starter-kit directory.
$ cd /opt/kickstart-linux
# Boot Linux VM using Vagrant.
$ sudo VAGRANT_CWD=./vagrant/$OS_NAME/$HYPERVISOR/$OS_ARCHITECTURE/$OS_EDITION vagrant up
# SSH to Linux VM using Vagrant.
$ sudo VAGRANT_CWD=./vagrant/$OS_NAME/$HYPERVISOR/$OS_ARCHITECTURE/$OS_EDITION vagrant ssh
# Exit from Linux VM.
$ exit
# Halt Linux VM using Vagrant.
$ sudo VAGRANT_CWD=./vagrant/$OS_NAME/$HYPERVISOR/$OS_ARCHITECTURE/$OS_EDITION vagrant halt
# Provision Linux VM using Vagrant.
$ sudo VAGRANT_CWD=./vagrant/$OS_NAME/$HYPERVISOR/$OS_ARCHITECTURE/$OS_EDITION vagrant provision
# Destroy Linux VM using Vagrant.
$ sudo VAGRANT_CWD=./vagrant/$OS_NAME/$HYPERVISOR/$OS_ARCHITECTURE/$OS_EDITION vagrant destroy