The Go Blog

Multipass

bantana
28 August 2019

introduction

What is multipass? Multipass is a lightweight VM manager for Linux, Windows and macOS. It's designed for developers who want a fresh Ubuntu environment with a single command. It uses KVM on Linux, Hyper-V on Windows and HyperKit 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. Since it supports metadata for cloud-init, you can simulate a small cloud deployment on your laptop or workstation.

Install

$ brew cask install multipass

Basic Usage

Help command

$ multipass launch --help

Usage: multipass launch [options] [[<remote:>]<image> | <url>]
Create and start a new instance.

Options:
  -h, --help           Display this help
  -v, --verbose        Increase logging verbosity, repeat up to three times for
                       more detail
  -c, --cpus <cpus>    Number of CPUs to allocate
  -d, --disk <disk>    Disk space to allocate. Positive integers, in bytes, or
                       with K, M, G suffix. Minimum: 512M.
  -m, --mem <mem>      Amount of memory to allocate. Positive integers, in
                       bytes, or with K, M, G suffix. Mimimum: 128M.
  -n, --name <name>    Name for the instance
  --cloud-init <file>  Path to a user-data cloud-init configuration, or '-' for
                       stdin

Arguments:
  image                Optional image to launch. If omitted, then the default
                       Ubuntu LTS will be used.
                       <remote> can be either ‘release’ or ‘daily‘. If <remote>
                       is omitted, ‘release’ will be used.
                       <image> can be a partial image hash or an Ubuntu release
                       version, codename or alias.
                       <url> is a custom image URL that is in http://, https://,
                       or file:// format.

Find available images

$ multipass find

Image                   Aliases           Version          Description
snapcraft:core          core16            20190819         Snapcraft builder for Core 16
snapcraft:core18                          20190820         Snapcraft builder for Core 18
16.04                   xenial            20190814         Ubuntu 16.04 LTS
18.04                   bionic,lts        20190813.1       Ubuntu 18.04 LTS

Launch a fresh instance of the current Ubuntu LTS

you can simple use $ multipass launch bionic , the instance vm while use the default value

my example create use -n (name) -d (disk usage) -m (amount of memory):

$ multipass launch -n myubuntu -d 4G -m 1G bionic

Downloading Ubuntu 18.04 LTS..........
Launched: myubuntu

Check out the running instances

$ multipass list

Name                    State             IPv4             Image
myubuntu                Running           192.168.64.5     Ubuntu 18.04 LTS

Learn more about the VM instance you just launched

$ multipass info myubuntu

Name:           myubuntu
State:          Running
IPv4:           192.168.64.5
Release:        Ubuntu 18.04.3 LTS
Image hash:     babd5399b947 (Ubuntu 18.04 LTS)
Load:           0.00 0.03 0.00
Disk usage:     990.4M out of 3.7G
Memory usage:   73.1M out of 986.0M

Connect to a running instance

$ multipass shell myubuntu
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-58-generic x86_64)

...

Don't forget to logout (or Ctrl-D) or you may find yourself heading all the way down the Inception levels... ;)

Run commands inside an instance from outside

$ multipass exec myubuntu -- lsb_release -a

No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 18.04.3 LTS
Release:    18.04
Codename:    bionic

Stop an instance to save resources

$ multipass stop myubuntu

Name                    State             IPv4             Image
myubuntu                Stopped           --               Ubuntu 18.04 LTS

Delete the instance

$ multipass delete myubuntu

It will now show up as deleted:

Name                    State             IPv4             Image
myubuntu                Deleted           --               Not Available

And when you want to completely get rid of it:

$ multipass purge

$ multipass list
No instances found.

Get help

multipass help
multipass help <command>

Get involved!

Here's a set of steps to build and run your own build of multipass:

Build Dependencies

cd <multipass>
apt install devscripts equivs
mk-build-deps -s sudo -i

Building

cd <multipass>
git submodule update --init --recursive
mkdir build
cd build
cmake ../
make

Running multipass daemon and client

sudo <multipass>/build/bin/multipassd &
<multipass>/build/bin/multipass launch --name foo

Related articles