Multipass is a platform developed by Canonical to launch and run Ubuntu virtual machines while offering a user the ability to configure them with cloud-init like a public cloud. Here we learn how to install Multipass on Ubuntu 20.04 Linux and use the same to launch Virtual machine instance.
Although when it comes to launching lightweight pre-built virtual machine images with just a command, Docker comes to mind, however, Multipass could be another option for those who love to work on Ubuntu Server. Yes, if you want to launch Ubuntu Linux command line server VMs instantly on Windows, Linux and macOS then cross-platform Multipass is one of the good options to consider.
Steps to Install and Use Multipass on Ubuntu 20.04
The following steps can be used for Ubuntu 18.04/21.04 including Linux Mint, MX Linux, Elementary OS, Zorin OS, and Debian.
1. Run system update
Just to update existing packages and for rebuilding repo cache, in the terminal run the system update command:
sudo apt update
2. Install Multipass on Ubuntu 20.04 LTS
Multipass is available via SNAP packages, thus to install it we should have Snapd on our system. The good thing is all the latest versions of Ubuntu comes with SNAP installed out of the box, thus simply run the below command:
sudo snap install multipass
3. Find Ubuntu VM on Multipass
There are multiple versions of Ubuntu Linux including some common web applications to install and launch as a virtual machine on Multipass.
We can see all the images of available VM instances using a command:
multipass find
While doing this article following images were available to use:
Image Aliases Version Description snapcraft:core18 20201111 Snapcraft builder for Core 18 snapcraft:core20 20201111 Snapcraft builder for Core 20 snapcraft:core 20210208 Snapcraft builder for Core 16 core core16 20200818 Ubuntu Core 16 core18 20200812 Ubuntu Core 18 16.04 xenial 20210128 Ubuntu 16.04 LTS 18.04 bionic 20210129 Ubuntu 18.04 LTS 20.04 focal,lts 20210223 Ubuntu 20.04 LTS 20.10 groovy 20210209 Ubuntu 20.10 daily:21.04 devel,hirsute 20210223 Ubuntu 21.04 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
4. Launch Instance Images
Once you decided which version of Ubuntu or Appliance you want to install as Virtual machines, use the Launch command of multipass, i.e-
multipass launch --name vm-name "Image Aliases"
In the above syntax replace VM-name with some label or name you want to give your virtual machine and at the place of “Image ” type the VM Image you want to use.
For example– we want to create a virtual machine on multipass of Core Ubuntu 18.04 and to identify the same, we will give it a label h2slinux. The Image ID you can find in the previous step of this article.
multipass launch --name h2slinus "core18"
5. Check VM Version
Once the installation is completed, we can check its version without actually connecting it, to know exactly which version of Image has been installed:
multipass exec vm-name -- lsb_release -a
or
multipass info vm-name
Replace vm-name with your given machine label
Example: multipass exec h2slinus -- lsb_release -a
5. Run Multipass installed VM instance Shell
Well, we have created and installed the VM instance of Core Ubuntu 18, now it’s time to connect and open a shell prompt on an instance. For that we in your command terminal type
multipass shell VM-name
Replace the VM-name in the above syntax with the label you have given while creating a virtual machine.
For example in our case it is h2slinus, thus the command will be:
multiplass shell h2slinus
6. Stop and Start VM
If you require to start and stop any of the installed VMs then we can use the following commands:
multipass stop vm-name
multipass start vm-name
7. Delete VMs
When the motive behind creating the Multipass VMs is completed, we can delete any of the installed one to free up space:
multipass delete vm-name
To clean
multipass purge
8. To see all installed Virtual Machines
List all the VMs using this syntax:
multipass list
If you want to transfer some data from the host machine to the guest VM created on Multiplass then we can do that easily by mounting it on the host system.
multipass mount $HOMEvm-name
Example: We want to mount our VM called h2slinus’s home directory on our host i.e Ubuntu 20.04 here, thus the command will be:
multipass mount $HOME h2slinus
You can mount the VM’s home directory to some particular folder path as well. Such as
multipass mount $HOME h2slinus:/folder/path
Replace h2slinus
with your instance name and /folder/path
where you want to mount it.
After running the above command on the host terminal, the home directory will common for both guest and host. Whatever file or folder we save in the /home
the directory can be accessed by the Multipass guest VM as well.
You can check that by typing:
multiplass info vm-name