DEV Community

Mario García
Mario García

Posted on • Edited on

Multipass: Ubuntu Virtual Machines Made Easy

Through the years, I've used different virtualization tools, mainly Open Source, as a way to test other Linux distributions, configure development environments, or to teach some concepts on various topics.

Some of these tools include Oracle VM VirtualBox (that I've used since before the acquisition of Sun Microsystems by Oracle), VMWare Workstation Player, and QEMU, but last year, I found out about Multipass.

The Fifth Element - Multipass Scene

No, not the one from that scene of The Fifth Element with Milla Jovovich as Leeloo.

What Is Multipass?

Multipass is a tool to generate cloud-style Ubuntu VMs quickly on Linux, macOS, and Windows. It gives you a simple but powerful CLI that allows you to quickly access an Ubuntu command line or create your own local mini-cloud.

It uses KVM on Linux, Hyper-V on Windows and QEMU on macOS to run the VM with minimal overhead. It can also use VirtualBox on Windows and macOS. Multipass will fetch images for you and keep them up to date.

Developed by Canonical.

Installation

Multipass is available as a Snap package on Linux. The snap daemon (snapd) is pre-installed on the following:

Otherwise, follow the instructions for your distributions in the docs.

Once snapd is available on your system, you can install Multipass by running the following command:



$ snap install multipass


Enter fullscreen mode Exit fullscreen mode

For architectures other than amd64, you’ll need the beta channel at the moment.

You can also use the edge channel to get the latest development build:



$ snap install multipass --edge


Enter fullscreen mode Exit fullscreen mode

If you want to uninstall Multipass, just run:



$ snap remove multipass


Enter fullscreen mode Exit fullscreen mode

To install on macOS, follow the instructions in the docs.

The docs also have instructions for installing Multipass on Windows.

Create an Instance

To create an instance, just run:



$ multipass launch


Enter fullscreen mode Exit fullscreen mode

The above command will create an instance using an image of the latest LTS version of Ubuntu (22.04.3). Multipass will assign a random name to the instance and it will apply default configuration.

You can list the instances on your system by running:



$ multipass list
Name                    State             IPv4             Image
visionary-longspur      Running           10.81.157.45     Ubuntu 22.04 LTS


Enter fullscreen mode Exit fullscreen mode

You can check the details of your instance with the following command:



$ multipass info visionary-longspur
Name:           visionary-longspur
State:          Running
IPv4:           10.81.157.45
Release:        Ubuntu 22.04.3 LTS
Image hash:     054db2d88c45 (Ubuntu 22.04 LTS)
CPU(s):         1
Load:           2.30 0.82 0.29
Disk usage:     1.4GiB out of 4.8GiB
Memory usage:   157.2MiB out of 951.9MiB
Mounts:         --


Enter fullscreen mode Exit fullscreen mode

By default, Multipass will assign the following resources:

  • 1 CPU
  • 5GB of disk
  • 1GB of RAM

Default user is ubuntu.

Create a Customized Instance

You can create a customized instance. First, check what images are available:



$ multipass find
Image                       Aliases           Version          Description
core                        core16            20200818         Ubuntu Core 16
core18                                        20211124         Ubuntu Core 18
core20                                        20230119         Ubuntu Core 20
core22                                        20230717         Ubuntu Core 22
20.04                       focal             20231011         Ubuntu 20.04 LTS
22.04                       jammy,lts         20231026         Ubuntu 22.04 LTS
23.04                       lunar             20231025         Ubuntu 23.04
23.10                       mantic,devel      20231011         Ubuntu 23.10
appliance:adguard-home                        20200812         Ubuntu AdGuard Home Appliance
appliance:mosquitto                           20200812         Ubuntu Mosquitto Appliance
appliance:nextcloud                           20200812         Ubuntu Nextcloud Appliance
appliance:openhab                             20200812         Ubuntu openHAB Home Appliance
appliance:plexmediaserver                     20200812         Ubuntu Plex Media Server Appliance

Blueprint                   Aliases           Version          Description
anbox-cloud-appliance                         latest           Anbox Cloud Appliance
charm-dev                                     latest           A development and testing environment for charmers
docker                                        0.4              A Docker environment with Portainer and related tools
jellyfin                                      latest           Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media.
minikube                                      latest           minikube is local Kubernetes
ros-noetic                                    0.1              A development and testing environment for ROS Noetic.
ros2-humble                                   0.1              A development and testing environment for ROS 2 Humble.


Enter fullscreen mode Exit fullscreen mode

Create an instance with the following configuration:

  • Ubuntu Mantic Minotaur (23.10)
  • Custom name: server
  • 2 CPUs
  • 10GB of disk
  • 2 GB of RAM


$ multipass launch mantic --name server --cpus 2 --disk 10G --memory 2G


Enter fullscreen mode Exit fullscreen mode

Where mantic is the name of the image being used for creating the instance.

Basic Commands

Open a Shell Prompt Inside an Instance

To open a shell prompt on an existing instance server, execute the following command:



$ multipass shell server
Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-87-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Fri Nov 10 01:32:53 CST 2023

  System load:  0.0               Processes:             90
  Usage of /:   30.9% of 4.67GB   Users logged in:       0
  Memory usage: 19%               IPv4 address for ens3: 10.81.157.45
  Swap usage:   0%


Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status


The list of available updates is more than a week old.
To check for new updates run: sudo apt update

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.


Enter fullscreen mode Exit fullscreen mode

The instance will be started automatically if it is stopped or suspended.

You can run commands as you would do on any Ubuntu installation.

Execute a Command Inside an Instance

Commands can be executed inside an instance directly from the host, by running



$ multipass exec server -- pwd
/home/ubuntu


Enter fullscreen mode Exit fullscreen mode

Transfer a File From the Host to the Instance

If you want to transfer a file, like a Bash script, from the host to the instance, run the following command:



$ multipass transfer install.sh server:/home/ubuntu/install.sh


Enter fullscreen mode Exit fullscreen mode

install.sh is the file from the host that will be transfered to the instance.

server is the name of the instance.

/home/ubuntu/install.sh is the path inside the instance where the file will be stored.

Change Status of the Instance

Stop an Instance

To stop an instance, run:



$ multipass stop server


Enter fullscreen mode Exit fullscreen mode

You can stop as many instances as needed with a single command:



$ multipass stop server server2 server3


Enter fullscreen mode Exit fullscreen mode

All running instances can be stopped at once:



$ multipass stop --all


Enter fullscreen mode Exit fullscreen mode

Start an instance

To start an instance, run:



$ multipass start server


Enter fullscreen mode Exit fullscreen mode

You can start as many instances as needed with a single command:



$ multipass start server server2 server3


Enter fullscreen mode Exit fullscreen mode

All stopped or suspended instances can be started at once:



$ multipass stop --all


Enter fullscreen mode Exit fullscreen mode

Suspend an instance

To suspend an instance, run:



$ multipass suspend server


Enter fullscreen mode Exit fullscreen mode

You can suspend as many instances as needed with a single command:



$ multipass suspend server server2 server3


Enter fullscreen mode Exit fullscreen mode

All running instances can be suspended at once:



$ multipass suspend --all


Enter fullscreen mode Exit fullscreen mode

Remove an instance

You can delete an instance by running the following command:



$ multipass delete server


Enter fullscreen mode Exit fullscreen mode

Or as many instances as needed:



$ multipass delete server server2 server3


Enter fullscreen mode Exit fullscreen mode

Running instances will be stopped and deleted.

After deleting an instance, run:



$ multipass purge


Enter fullscreen mode Exit fullscreen mode

The multipass purge command will permanently remove all instances deleted with the multipass delete command. This will destroy all the traces of the instance, and cannot be undone.

You're ready to go. Ubuntu VMs can be created at ease using Multipass.


Support me on Buy Me A Coffee

Top comments (0)