Easy minimal Ubuntu VM on any OS

K Prayogo
2 min readJan 21, 2022

for better reading experience (code formatting), read on the original blog, link on bottom section of this post.

Normally we use LXC/LXD, KVM, QEMU, Docker, Vagrant, VirtualBox, VMWare or any other virtualization and containerization software to spawn a VM-like instance locally. Today we’re gonna try multipass, a tool to spawn and orchestrate ubuntu VM. To install multipass, it’s as easy as running these commands:

snap install multipass
ls -al /var/snap/multipass/common/multipass_socket
snap info multipass

To spawn a VM on Ubuntu (for other OSes, see the link above), we can run:

multipass find

Image Aliases Version Description
snapcraft:core18 18.04 20201111 Snapcraft builder for Core 18
snapcraft:core20 20.04 20210921 Snapcraft builder for Core 20
snapcraft:core 16.04 20210929 Snapcraft builder for Core 16
core core16 20200818 Ubuntu Core 16
core18 20211124 Ubuntu Core 18
18.04 bionic 20220104 Ubuntu 18.04 LTS
20.04 focal,lts 20220118 Ubuntu 20.04 LTS
21.10 impish 20220118 Ubuntu 21.10
daily:22.04 devel,jammy 20220114 Ubuntu 22.04 LTS
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
anbox-cloud-appliance latest Anbox Cloud Appliance
charm-dev latest A development and testing environment for charmers
minikube latest minikube is local Kubernetes

multipass launch — name groovy-lagomorph # 20.04

multipass list
Name State IPv4 Image
groovy-lagomorph Running 10.204.28.99 Ubuntu 20.04 LTS

multipass info — all
Name: groovy-lagomorph
State: Running
IPv4: 10.204.28.99
Release: Ubuntu 20.04.3 LTS
Image hash: e1264d4cca6c (Ubuntu 20.04 LTS)
Load: 0.00 0.00 0.00
Disk usage: 1.3G out of 4.7G
Memory usage: 134.2M out of 976.8M
Mounts: —

To run shell inside newly spawned VM, we can run:

multipass shell groovy-lagomorph

multipass exec groovy-lagomorph — bash

If you need to simulate ssh, according to this issue you can either:

sudo ssh -i /var/snap/multipass/common/data/multipassd/ssh-keys/id_rsa ubuntu@10.204.28.99

# or add ssh key before launch on cloud-init.yaml
ssh_authorized_keys:
— <your_ssh_key>

# or copy ssh key manually after launch
sudo ssh-copy-id -f -o ‘IdentityFile=/var/snap/multipass/common/data/multipassd/ssh-keys/id_rsa’ -i ~/.ssh/id_rsa.pub ubuntu@10.204.28.99

If to stop/start/delete the VM:

multipass stop groovy-lagomorph
multipass start groovy-lagomorph
multipass delete groovy-lagomorph
multipass purge

What technology used by multipass? it’s QEMU, but maybe it’s different on another platform (it can run on Windows and MacOSX too).

Originally published at http://kokizzu.blogspot.com.

--

--