Multipass For Easy Ubuntu VMs On M1 Macs
As someone who wears out Udemy for keeping on top of new things that I want to learn — and considering most of those things are typically tech-related — I tend to go through a lot of VMs as I test things, build out servers, etc. While going through a recent training on Jenkins, I needed a VM to act as my Jenkins server. The training itself used CentOS, but I had decided to use Ubuntu since it’s my go-to flavor of Linux for pretty much everything server-related. (On my laptop, I use the Ubuntu-based Pop!_OS.)
I’ve typically used VMware Fusion Pro for my virtualization needs, which I have a license for from work. It doesn’t play nice with M1 Macs, though, which is what I’m currently using. There’s a technical preview of Fusion Pro for Apple silicon, which I’ve been using for some things I’ve been testing with Alpine Linux; I know I said Ubuntu was my go-to, but sometimes image size matters.
Building an Ubuntu server VM with the technical preview, however, started to give me some problems. When booting, my VM would become hung with a message:
EFI stub: Exiting boot services and installing virtual address map…
While trying to search for solutions online, I didn’t have much lucky with anything specific to the VMware Fusion Pro tech preview. However, I found this thread with the same issue being experienced on another virtualization platform, seemingly related to the graphics. While that in itself wasn’t particularly helpful, there was a recommendation to use Multipass with M1 devices instead. Having zero familiarity with Multipass other than assuming it’s a reference to The Fifth Element, I decided to do some digging.
The goal according to the official site is:
Get an instant Ubuntu VM with a single command. Multipass can launch and run virtual machines and configure them with cloud-init like a public cloud. Prototype your cloud launches locally for free.
That sounds like… exactly what I need. While you can swap the virtualization technology used under the hood, out of the box it uses HyperKit on macOS, the same thing powering Docker Desktop. If you’re curious, it leverages KVM on Linux and Hyper-V on Windows.
After installation, the multipass CLI was automatically included in my $PATH. I could spin up my new Jenkins VM with:
multipass launch --name jenkins
Note that the name value is just for my own benefit to keep straight which VMs serve what purpose. Typically, Multipass interaction is issuing commands from the CLI to be executed within the VM and reported back. For example, from their own documentation to run lsb_release inside of a VM named “foo” you would run:
multipass exec foo -- lsb_release -a
I really needed my VM to be a bit more interactive, though, so simply running this gave me the full list of options:
multipass help
This let me see that I could get an interactive shell via:
multipass shell jenkins
From there I could patch the system, install Jenkins, and take any other configuration steps that I needed. sudo access works out of the box without any additional password. The VMs get an IP on my local network, and I can easily reference that IP to access services they happen to host, such as the web frontend of Jenkins on port 8080.
As I worked through the training, I could stop the VM when I didn’t need it by running:
multipass stop jenkins
Once I was finished and no longer needed it at all, I could delete the VM with:
multipass delete jenkins
This places the VM in a deleted state but doesn’t fully remove it. To fully nuke anything that is pending a full deletion, run:
multipass purge
While the very first deployment I did required a slight wait for the image to download, subsequent VMs launch almost immediately since they don’t need to wait on the same download. By default, Multipass will create new VMs on the latest LTS release of Ubuntu; that’s great for me since I tend to favor LTS releases for my production workloads as well. Different images can be discovered and selected, though. Dumping all of my current VMs and their state to the screen is as simple as:
multipass list
This makes it easy to see what I have, what’s running, and what may need to be purged. On the whole, Multipass is an extremely slick tool that I’m disappointed I didn’t start leveraging sooner. If you need quick, easy VMs with little overhead, you’ll be hard pressed to find a better solution. And they work great on Apple silicon!