Cloud Computing 11 min read

Quickly Spin Up Ubuntu VMs on macOS with Multipass: A Step‑by‑Step Guide

This guide shows how to install Multipass on macOS, create and manage lightweight Ubuntu virtual machines using simple CLI commands, configure resources, mount volumes, transfer files, and automate setup with cloud‑init, providing a fast alternative to heavyweight virtualization tools for local development.

macrozheng
macrozheng
macrozheng
Quickly Spin Up Ubuntu VMs on macOS with Multipass: A Step‑by‑Step Guide

Looking for a lightweight way to run Ubuntu virtual machines on a Mac for learning Kubernetes, the author tried VMware, Parallels Desktop, and VirtualBox but faced issues, then discovered Multipass, an open‑source VM manager from Canonical.

What is Multipass?

Multipass is a lightweight VM manager that runs on Linux (using KVM), Windows (using Hyper‑V), and macOS (using HyperKit). It quickly creates Ubuntu instances with a single command and supports minimal overhead, making it suitable for local cloud‑like environments.

Installing Multipass on macOS

Download the installer from multipass.run or, if Homebrew is installed, run:

<code>brew cask install multipass</code>

Verify the installation:

<code>multipass --version</code>

Creating an Ubuntu VM

List available images:

<code>multipass find</code>

Launch a VM with custom resources (name, CPU, memory, disk):

<code>multipass launch -n vm01 -c 1 -m 1G -d 10G</code>

Available options:

<code>-n, --name: VM name
-c, --cpus: number of CPU cores (default 1)
-m, --mem: memory size (default 1G)
-d, --disk: disk size (default 5G)</code>

Managing the VM

List VMs

<code>multipass list</code>

Execute commands inside the VM

<code># multipass exec vm01 pwd
/home/ubuntu</code>

Show VM information

<code>multipass info vm01</code>

Enter the VM shell

<code>multipass shell vm01</code>

Basic Operations Inside the VM

Set a root password and switch to the root user:

<code># sudo passwd
# su root</code>

Update packages and install Nginx:

<code># apt-get update
# apt-get install nginx</code>

Verify Nginx is running by opening

http://192.168.64.2

in a browser on the host.

Mounting and Transferring Files

Mount a host directory into the VM (similar to Docker volumes):

<code># mkdir hello
# multipass mount /Users/moxi/hello vm01:/hello</code>

Transfer a single file:

<code>multipass transfer hello.txt vm01:/home/ubuntu/</code>

Stopping, Deleting, and Purging VMs

<code># multipass start vm01
# multipass stop vm01
# multipass delete vm01   # marks for deletion
# multipass purge vm01   # permanently removes</code>

Automating Setup with Cloud‑Init

Use the

--cloud-init

option to run a configuration file when the VM first boots:

<code>multipass launch --name ubuntu --cloud-init config.yaml</code>

Example

config.yaml

to install Node.js:

<code>#cloud-config
runcmd:
  - curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
  - sudo apt-get install -y nodejs</code>

Conclusion

Multipass offers a simple, Docker‑like experience for quickly provisioning Ubuntu VMs on macOS, making it an efficient tool for local development and testing of Linux‑based workloads.

cliDevOpsVirtual MachinemacOSubuntuCloud‑InitMultipass
macrozheng
Written by

macrozheng

Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.