Multipass Ubuntu VMs on demand

Version 1.16 · source

Start here

multipass launch lts --name <name>
Create a VM
multipass list
See your VMs
multipass shell <name>
Log in
multipass exec <name> -- <cmd>
Run one command
multipass transfer <file> <name>:.
Copy a file in
multipass stop <name>
Shut it down
multipass delete <name>
Remove it
multipass purge
Free the disk space

Concepts

  1. Image Ubuntu release
  2. Running instance
  3. Stopped snapshots here
  4. Deleted recoverable
  5. Gone disk freed

Create and inspect

multipass launch [<image>] --name <name>
Create and start an instance
multipass launch --cpus <n> --memory <size> --disk <size>
Set the VM resources
Defaults are 1 CPU, 1G memory and 5G disk.
multipass images
List available images
multipass list
List instances and their IPs
multipass info <name>
Show details of an instance
multipass list --format json
Machine-readable list
multipass info --all
Details of every instance
multipass launch --cloud-init <file>
Configure at first boot
multipass launch --mount <host-dir>:<vm-dir>
Mount a folder at launch
multipass launch --network <spec>
Add a network interface
multipass launch --bridged
Add a bridged network
multipass launch --timeout <seconds>
Allow a slow start
multipass networks
List host networks
multipass clone <name> --name <new>
Copy a stopped instance

Access

multipass shell [<name>]
Open a shell in the instance
multipass exec <name> -- <cmd>
Run a command in the instance
multipass exec <name> --working-directory <dir> -- <cmd>
Run in a given directory
multipass exec <name> -- <cmd> | grep <text>
Pipe the output to the host
multipass alias <name>:<cmd> [<alias>]
Run a VM command from the host
multipass aliases
List defined aliases
multipass unalias <alias>
Remove an alias

Lifecycle

multipass stop <name>
Stop an instance
multipass start <name>
Start a stopped instance
multipass restart <name>
Restart an instance
multipass suspend <name>
Suspend, keeping memory state
multipass stop --all
Stop every instance
multipass stop --force <name>
Force off immediately
Can corrupt the instance; needs Multipass 1.14 or newer.
multipass delete <name>
Delete (recoverable)
multipass recover <name>
Bring back a deleted instance
multipass purge
Permanently remove deleted instances
multipass delete --purge <name>
Delete and purge at once

Files

multipass transfer <file> <name>:<path>
Copy host file to instance
multipass transfer <name>:<path> <dest>
Copy instance file to host
multipass transfer --recursive <src> <name>:<path>
Copy a directory tree
multipass transfer --parents <file> <name>:<path>
Create missing target dirs
multipass mount <host-dir> <name>:<vm-dir>
Share a host folder
multipass mount --type native <host-dir> <name>:<vm-dir>
Use a native mount
multipass unmount <name>[:<path>]
Remove a mount

Snapshots

multipass snapshot <name> --name <snap>
Snapshot a stopped instance
multipass snapshot <name> --comment "<text>"
Add a note to the snapshot
multipass snapshots
List snapshots
multipass restore <name>.<snap>
Roll back to a snapshot
multipass restore --destructive <name>.<snap>
Roll back without saving state
multipass info --snapshots <name>
Snapshot details
multipass delete <name>.<snap>
Delete a snapshot for good

Settings

multipass get --keys
List all setting keys
multipass get <key>
Read a setting
multipass set client.primary-name=<name>
Rename the primary instance
multipass set local.driver=<driver>
Choose the hypervisor
multipass set local.<name>.cpus=<n>
Resize a stopped instance's CPUs
multipass set local.<name>.memory=<size>
Resize its memory
multipass set local.<name>.disk=<size>
Grow its disk
multipass set local.privileged-mounts=true
Allow mounts as host root
multipass version
Show client and daemon versions
multipass help <command>
Help for one command

Recipes

Throwaway test box
multipass launch 24.04 --name scratchmultipass exec scratch -- sudo apt-get install -y <pkg>multipass delete --purge scratch
Share project, work inside
multipass launch --name dev --cpus 2 --memory 4Gmultipass mount ~/<project> dev:/home/ubuntu/<project>multipass shell dev
Checkpoint before risky change
multipass stop devmultipass snapshot dev --name before-upgrademultipass start dev# if it goes wrongmultipass stop dev && multipass restore dev.before-upgrade
Provision with cloud-init
# cloud.yaml starts with #cloud-configmultipass launch --name web --cloud-init cloud.yamlmultipass exec web -- cloud-init status --wait