Introduction

In the virtualization field, there are many products to choose from, both free and commercial, but most of them specialize in only one area. For developers, deploying virtual machines on different systems can be quite troublesome. This is especially true with hardware like Apple Silicon, which prevents VMware Workstation and Virtualbox from running on such hardware.

Multipass is similar to the Vagrant project, abstracting the underlying virtualization technology to achieve cross-platform native virtualization compatibility.

  • Hyper-V on Windows
  • QEMU and HyperKit on macOS
  • LXD on Linux
  • Virtualbox on x86 Arch

As you can see, in addition to supporting virtualization technologies for other system platforms, it also supports using Virtualbox as the underlying virtualization implementation. However, since Virtualbox can only run on CPUs with x86 architecture, it cannot be used on Apple Silicon.

Installation

I’m using an M1 MacBook. For installation methods on other platforms, please refer to the official documentation.

There are two ways to install on macOS. One is to download the latest version of the installation package, and the other is to install via Homebrew:

brew install --cask multipass

Default Network Segment

This configuration is optional. Since I want to use Multipass to set up a Kubernetes cluster environment, and the default network segment for macOS virtual machines is 192.168.64.0/24, which conflicts with Kubernetes Pod’s 192.168.0.0/16 network segment, I need to manually change the default network segment for macOS.

Edit the value corresponding to the Shared_Net_Address key in the /Library/Preferences/SystemConfiguration/com.apple.vmnet.plist file. This value is the Gateway address. I changed it to 10.0.8.1, and kept the value of Shared_Net_Mask unchanged, still with a 24-bit mask. If you need a larger network segment, you can use an online IP range calculator to generate and replace the subnet mask here.

Commands

View Available System Images

multipass find
Image                       Aliases           Version          Description
18.04                       bionic            20220921         Ubuntu 18.04 LTS
20.04                       focal             20220920         Ubuntu 20.04 LTS
22.04                       jammy,lts         20220923         Ubuntu 22.04 LTS
anbox-cloud-appliance                         latest           Anbox Cloud Appliance
charm-dev                                     latest           A development and testing environment for charmers
docker                                        latest           A Docker environment with Portainer and related tools
jellyfin                                      latest           Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media.
minikube                                      latest           minikube is local Kubernetes

Create a Virtual Machine

multipass launch lts --name s01 --disk 40G --cpus 2 --mem 4G

Parameters:

  • name: Set the VM name
  • disk: Set the VM disk size
  • cpus: Set the number of CPU cores
  • mem: Set the memory size

If you need multiple network interfaces, please refer to the official documentation.

Login to VM

multipass shell s01

Stop, Delete, and Clean Up

multipass stop s01
multipass delete s01
multipass purge

The multipass delete command does not physically delete the virtual machine. You will find that after deletion, the virtual machine will still be in the list. If you want to completely delete it, you need to execute the multipass purge command to clean up!

Create Docker VM

This is where the true charm of Multipass lies. The image starts up as a Docker runtime environment without the need for manual installation.

multipass launch docker

Conclusion

Multipass’s simplicity and efficiency save developers a lot of time and effort, allowing them to focus on upper-layer services rather than virtual machine configuration and operating system installation. However, there are also some issues, such as the current lack of support for snapshot functionality.

I hope this is helpful, Happy hacking…