Multipass on macOS
Table of Contents
Updated on: 13/05/22
Multipass is a VM manager for Official Ubuntu Images. It can also deploy a VM through cloud-init
(only with providers that supports cloud-init). I’ll just use multipass
to run a generic Ubuntu.
Native Hypervisors is used by default. On macOS, this would be hyperkit
(maintained by the creators of docker). VirtualBox is also supported, but hyperkit is lightweight , and way faster. You read more about it here.
Unfortunately, to get a network interface that you can access from your local network, you would’ve to enable virtualbox
.
Installation #
Multipass supports all major platforms. Follow the instructions here to install it.
Once the installation is completed, run the following, to verify the installed version and your default hypervisor:
multipass version; echo; sudo multipass get local.driver
Find and launch Images #
Find images by running multipass find
:
MacBook-Pro:~ kavish$ multipass find
Image Aliases Version Description
snapcraft:core18 20201111 Snapcraft builder for Core 18
snapcraft:core20 20201111 Snapcraft builder for Core 20
snapcraft:core 20210119 Snapcraft builder for Core 16
16.04 xenial 20210119 Ubuntu 16.04 LTS
18.04 bionic 20210119.1 Ubuntu 18.04 LTS
20.04 focal,lts 20210119.1 Ubuntu 20.04 LTS
20.10 groovy 20210119.1 Ubuntu 20.10
The launch
command will create and start a VM by specifying an alias. If no alias was specified, the LTS
version will be installed by default(in this case 18.04 focal, and a random generated name as its name). Just by running a simple command like multipass launch -n localubuntu
, it will retrieve the image, install it automatically, and start the VM. You don’t have to dowload an iso, or waste your time going through the installation process.
Run it, and go grab a coffee:
multipass launch -n localubuntu
When it’s done, you’ll see: Launched: localubuntu
.
Note: The
Retrieving image
part is only done once. Now, the base image is saved on disk(think of it like an iso). The next time you runmultipass launch -n [vm_name]
, it will just use that available image to create a new VM. If you launched another Ubuntu distro, then it will have to retrieve it.
To list all your available VMs:
multipass list
Info #
To get the info of a specific VM, run multipass info [vm_name]
:
MacBook-Pro:~ kavish$ multipass info localubuntu
Name: localubuntu
State: Running
IPv4: N/A
Release: Ubuntu 20.04.1 LTS
Image hash: c2d26335116d (Ubuntu 20.04 LTS)
Load: 0.00 0.06 0.07
Disk usage: 1.2G out of 4.7G
Memory usage: 115.7M out of 981.3M
By default, launch
will allocate 1 CPU, 1G of Memory, and 5G of Disk space. You can’t change those resources once it’s already created(except the CPU). It has to be specified at launch. Like this:
multipass launch -n testVM --mem 2G --cpus 2 --disk 7G focal
Getting a shell #
To get a shell, simply run multipass shell [vm_name]
:
MacBook-Pro:~ kavish$ multipass shell localubuntu
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-62-generic x86_64)
System information as of Tue Jan 26 11:50:48 +04 2021
System load: 0.08 Processes: 98
Usage of /: 26.7% of 4.67GB Users logged in: 0
Memory usage: 16% IPv4 address for enp0s3: 10.0.2.15
Swap usage: 0%
1 update can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable
Last login: Tue Jan 26 11:48:07 2021 from 10.0.2.2
ubuntu@localubuntu:~$
Run exit
to get out of the shell.
Note:
launch
is only used to create a VM. To start/stop the VM, runmultipass [start OR stop] [vm_name]
.
Arbitrary commands can also be executed. The syntax is multipass exec [vm_name] -- [command]
. Here’s an example:
multipass exec localubuntu -- uname -a
The double-dash --
is just a separator.
Deleting VMs #
To delete a VM, run:
multipass delete [vm_name]]
It’s not deleted yet. VMs will reside in some sort of recycle bin. It can be recovered with multipass recover [vm_name]
. To delete all deleted instances, run multipass purge
.
There’s also a shortcut: multipass delete [vm_name] --purge
Primary Instance #
A Primary instance is just an LTS ubuntu VM that gets created or started, only if no [vm_name]
was specified.
For example, if you run multipass launch
or multipass shell
, a primary instance will be created. The difference is, it uses your workstation’s home directory. Like on my machine, it’s using my mac’s \home
directory.
Location of Images #
They are found in:
/private/var/root/Library/Caches/multipassd/virtualbox/vault/images
/private/var/root/Library/Caches/multipassd/vault/images
As of now, images can only be deleted manually.
Be aware when switching hypervisor #
Each has their own folder. So when swtiching, the one in hyperkit won’t appear in virtualbox, and vice versa.
Enabling Virtualbox #
Only use it if you want the VM to access your local network:
sudo multipass set local.driver=virtualbox
Here’s all the available commands:
Available commands:
delete Delete instances
exec Run a command on an instance
find Display available images to create instances from
get Get a configuration setting
help Display help about a command
info Display information about instances
launch Create and start an Ubuntu instance
list List all available instances
list-networks List available network interfaces
mount Mount a local directory in the instance
purge Purge all deleted instances permanently
recover Recover deleted instances
restart Restart instances
set Set a configuration setting
shell Open a shell on a running instance
start Start instances
stop Stop running instances
suspend Suspend running instances
transfer Transfer files between the host and instances
umount Unmount a directory from an instance
version Show version details
Read the documentation to learn more.
““Keep your expectations low, and you will never be disappointed.”
― God of War