Quickly Set Up Ubuntu VMs on macOS Using Multipass
This guide walks you through installing Multipass on macOS, creating and configuring lightweight Ubuntu virtual machines, managing them via the CLI, mounting data volumes, and automating setup with cloud‑init, providing a fast, Docker‑like development environment.
Overview
Multipass is an open‑source lightweight VM manager from Canonical. It runs on Linux, Windows and macOS and uses native hypervisors (KVM, Hyper‑V, HyperKit) to launch Ubuntu instances with minimal overhead.
Installation on macOS
If Homebrew is installed: brew install --cask multipass Verify the installation:
multipass --versionCreating an Ubuntu instance
List available images: multipass find Launch a VM named vm01 with 1 CPU, 1 GB RAM and 10 GB disk: multipass launch -n vm01 -c 1 -m 1G -d 10G Common launch options: -n, --name: instance name -c, --cpus: number of CPU cores (default 1) -m, --mem: memory size (default 1G) -d, --disk: disk size (default 5G)
Managing the instance
Listing instances
multipass listTypical output shows name, state, IPv4 address and image.
Executing commands
# Run a command inside vm01
multipass exec vm01 -- pwd
# Open an interactive shell
multipass shell vm01Root access
# Set root password
sudo passwd
# Switch to root
su rootPackage management (Ubuntu)
# Update package index
apt-get update
# Install nginx
apt-get install -y nginxConfiguration files appear under /etc/nginx.
Data volume mounting
Mount a host directory into the VM (similar to Docker): multipass mount /path/on/host vm01:/path/in/vm Unmount: multipass umount vm01 Transfer a single file:
multipass transfer localfile.txt vm01:/home/ubuntu/Automating instance configuration
Use --cloud-init with a cloud‑init YAML file. Example config.yaml installs Node.js on first boot:
#cloud-config
runcmd:
- curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
- sudo apt-get install -y nodejsLaunch with cloud‑init:
multipass launch --name ubuntu --cloud-init config.yamlLifecycle commands
multipass start vm01 multipass stop vm01 multipass delete vm01– marks for deletion multipass purge vm01 – removes permanently
Additional notes
Multipass only provides Ubuntu images, which may be a limitation for users preferring other distributions. All commands shown assume a default Ubuntu 20.04 LTS image, but other releases (e.g., 18.04, 21.04) are available via multipass find.
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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
