Advanced setup tips for Multipass 1.12.x

; Date: Sat Jan 06 2024

Tags: Ubuntu »»»» Multipass

Multipass is an excellent tool for running Ubuntu on Linux, macOS or Windows laptops. It includes some advanced features for "power users".

Out of the box you run multipass launch --name instance-name OS-VERSION to launch a new Multipass instance. The default allocates 2GB of memory, a single core, a small amount of disk space, and the latest version of Ubuntu. That will serve a large number of purposes, but there are ways to enable additional functionality.

Creating a Multipass instance from a specific OS image

The Multipass team is always adding new, er, recipes for initializing the operating system running inside the virtual machine. Given that Multipass is sponsored by Canonical, the makers of Ubuntu, the choices are all based on Ubuntu.

To view the list of available Multipass images:

$ multipass find

Currently these include:

  • Appliance images for Mosquitto (the MQTT service), NextCloud, OpenHAB, and Plex
  • Docker - which is Ubuntu with pre-installed Docker and Portainer.
  • Minikube - which is a local Kubernetes instance.
  • Various Ubuntu versions

For example, the current Ubuntu LTS version is 22.04, code-named jammy. The current non-LTS version is 23.04, code-named lunar. To launch such a machine:

$ multipass launch --name INSTANCE-NAME lunar

In addition to the available images are "blueprints". These are defined by a YAML file describing how to customize an OS image to pre-install a given application. For more information, see: (github.com) https://github.com/canonical/multipass-blueprints

The prebaked blueprints are installed the same way:

$ multipass launch --name docker1 docker

This creates an instance named docker1 with a pre-installed Docker, along with pre-installed Portainer.

Modify memory, CPU, and disk allotment

The default allotments may not be enough for the specific application. Try this:

$ multipass launch --name bigger --cpus 4 --disk 200G --memory 8G jammy

These settings are made during creation of the instance. You can also change them afterwards using the multipass set command.

$ multipass get --keys
# ...
local.primary.cpus
local.primary.disk
local.primary.memory
# ...

The get --keys command lists all available settings. The ones with the pattern local.INSTANCE are related to a specific instance.

$ multipass stop INSTANCE
$ multipass set local.INSTANCE.memory=4G
# ...
$ multipass start INSTANCE

Attaching external storage to a Multipass instance

An issue with Multipass is that everything is stored within the virtual disk image. Deleting the instance deletes any data you have stored inside the instance.

You can use multipass transfer to transfer files in and out of the instance. But that's a little clumsy.

It's easy to mount a host directory into the image. This directory is shared between the two. Application data stored in that directory is automatically stored in the host filesystem. Such data is persistent even when destroying the instance.

$ multipass launch --name INSTANCE --mount /Volumes/Instances/INSTANCE:/data jammy

With the --mount option, a host directory appears inside the instance with a given pathname. In this case /Volumes/Instances/INSTANCE appears as /data.

To mount a host directory after the instance has been launched:

$ multipass mount /some/host/path INSTANCE:/some/instance/path

A directory can be unmounted just as easily:

$ multipass umount INSTANCE:/some/instance/path

Making a Multipass instance visible on the local network

By default Multipass instances are only visible to the host machine. While that's okay for software development, for production use, or for testing your application on multiple devices, it's useful if other machines can access your Multipass instance.

When creating an instance the --network option configures the networking. There are many complex things you can do with Multipass networking. For example, it's easy to create a virtual network segment connecting multiple instances together, which are completely private.

Making a Multipass instance visible on the local network requires adding a second interface which attempts to use DHCP to be assigned an IP address etc.

$ multipass launch --name INSTANCE --network en0 \
        --network name=en1,mode=auto \
        jammy

This sets up two interfaces, en0 and en1. The second is what connects to the local network.

To view the available network interface names:

$ multipass networks
Name     Type         Description
bridge0  bridge       Network bridge with en2
en0      ethernet     Ethernet
en1      wifi         Wi-Fi
en2      thunderbolt  Thunderbolt 1

This is what's available on my macOS laptop. It is solely connected with WiFi to the router.

The name=en1,mode=auto construct is, based on my experimentation, required to connect with DHCP on the WiFi router. The parameters which can be used are:

  • name — the only required value, it identifies the host network to connect the instance’s device to (see networks for possible values)
  • mode — either auto (the default) or manual; with auto, the instance will attempt automatic network configuration
  • mac — a custom MAC address to use for the device

Customize the Multipass instance

The multipass launch command takes an option, --cloud-init, with which you specify a file describing how to customize the instance. Unfortunately the documentation is woefully lacking.

$ multipass launch --name INSTANCE --cloud-init FILE jammy

Cloud Init ( (cloud-init.io) https://cloud-init.io/) is another Canonical project which they describe as the standard for customizing machines in cloud deployment. I think there are multiple tools for that purpose. In any case, reading the documentation left me confused as to how to proceed.

About the Author(s)

(davidherron.com) David Herron : David Herron is a writer and software engineer focusing on the wise use of technology. He is especially interested in clean energy technologies like solar power, wind power, and electric cars. David worked for nearly 30 years in Silicon Valley on software ranging from electronic mail systems, to video streaming, to the Java programming language, and has published several books on Node.js programming and electric vehicles.