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.
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: brew cask install multipass Verify the installation:
multipass --versionCreating an Ubuntu VM
List available images: multipass find Launch a VM with custom resources (name, CPU, memory, disk): multipass launch -n vm01 -c 1 -m 1G -d 10G Available options:
-n, --name: VM name
-c, --cpus: number of CPU cores (default 1)
-m, --mem: memory size (default 1G)
-d, --disk: disk size (default 5G)Managing the VM
List VMs
multipass listExecute commands inside the VM
# multipass exec vm01 pwd
/home/ubuntuShow VM information
multipass info vm01Enter the VM shell
multipass shell vm01Basic Operations Inside the VM
Set a root password and switch to the root user:
# sudo passwd
# su rootUpdate packages and install Nginx:
# apt-get update
# apt-get install nginxVerify 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):
# mkdir hello
# multipass mount /Users/moxi/hello vm01:/helloTransfer a single file:
multipass transfer hello.txt vm01:/home/ubuntu/Stopping, Deleting, and Purging VMs
# multipass start vm01
# multipass stop vm01
# multipass delete vm01 # marks for deletion
# multipass purge vm01 # permanently removesAutomating Setup with Cloud‑Init
Use the --cloud-init option to run a configuration file when the VM first boots:
multipass launch --name ubuntu --cloud-init config.yamlExample config.yaml to install Node.js:
#cloud-config
runcmd:
- curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
- sudo apt-get install -y nodejsConclusion
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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
