Lead Image © Liubomyr Feshchyn, 123rf.com

Lead Image © Liubomyr Feshchyn, 123rf.com

Goodbye cloud VMs, hello laptop VMs

Local Launch

Article from ADMIN 69/2022
Multipass lets you launch and run Ubuntu virtual machines, use cloud-init to configure the VMs, and prototype cloud launches locally in minutes.

In a previous article [1], I explored how to bring up cloud-like virtual machine stacks on a laptop with container machine tooling. That approach didn't require a lot of computing resources or any hardware-based virtualization support. However, security is a downside of containers because they provide thinner isolation compared with the strong isolation provided by virtual machines. Does a lightweight and fast solution exist to create cloud VM types of stacks on a laptop? Also desirable is tooling that works out of the box without a lot of dependencies to gather, install, and so on. The answer is "Yes." You can have your cake and eat it too with Multipass [2]!

The tooling provided in this article is for newer machines that have virtualization capability provided by the processor. Still, the container machine approach presented in the previous article is an option, in case you don't have such hardware available. I tested the snippets shown or referenced in this article on my four-core, 8GB COREi7 laptop running Ubuntu 18.04 LTS, but I have also used the tool on macOS in a professional setting.

CloudVMs Through Multipass

Multipass [3] is a tool to bring up Ubuntu virtual machines that, like public cloud VMs, can be configured by cloud-init. The tool is a lightweight, cross-platform, virtual machine manager (VMM) that uses the standard underlying hypervisors on the respective platform to keep the overhead minimal. With Multipass, you can enact a public-cloud-like VM environment anywhere on demand.

Getting Started

To begin, install the latest stable version Multipass on an Ubuntu machine through snap mechanism:

sudo snap install multipass

You can also see the available channels and respective versions (e.g., candidate/beta/edge) and install one of the alternatives:

snap info multipass
sudo snap refresh multipass <--stable|--candidate|--beta|--edge>

Executing the multipass command in your terminal should dump a help screen (Figure 1).

Figure 1: Multipass help screen.

You need to find an appropriate Ubuntu cloud image to instantiate your first VM. The command

multipass find

dumps all available and supported images (Figure 2). You could also append the --unsupported option, if you want to experiment with old unsupported versions of Ubuntu, or filter the images by appending a <remote>, which is either release: or daily:. To get information about the default image, include default, with or without a remote.

Figure 2: Multipass find output.

Local Cloud VM

To bring up a local Ubuntu VM with the default image, enter

multipass launch

Appending a desired image or alias to the command instantiates the VM with that particular image. Table 1 shows the various arguments you can append to the launch command. For example, the command

multipass launch -n mycloudvm -c 2 -m 2G -d 10G --timeout 600

Table 1

Multipass launch

Argument Action (v1.8.0 default)
-n <NAME> Override the auto-generated name with a name of your choice (random name).
-c <NumOfCPUs> Specify the number of CPUs (1).
-m <AmountOfMemory> Specify memory to allocate (1GB).
-d <DiskSpace> Specify storage space (5GB).
--timeout <TimeoutInSecs> Maximum time in seconds to bring up the VM instance (max 5min).

brings up a local VM with the default LTS release version of Ubuntu (20.04 as of this writing) named mycloudvm with two CPUs, 2GB of memory, 10GB of disk space, and a launch operation timeout of 10min.

The commands

multipass list
multipass info --all

dump all information about the launched instances. The info command adds some extra runtime details. This information could be dumped in other than the default format (a table for v1.8.0) by appending --format <json|csv|yaml> to the list or info command. Once your instance is up, use

multipass shell <VMName>

to log in. Now your local cloud VM instance is ready to be used as per your desire (Figure 3).

Figure 3: A local cloud VM instance created by Multipass.

If you don't provide a name for the VM, an instance named primary with default resources is created (if it does not already exist). The primary instance automounts your home directory, but you could unmount that instance with the command:

multipass unmount primary

If you want to set the name of the primary instance to something other than the default, you can use the command:

multipass set client.primary-name=<CustomPrimaryName>

Similarly, the multipass start command launches a primary instance if one has not been created already.

To execute any shell command on a running instance, use multipass exec. Logically, you could combine transfer and exec to copy and execute your configuration scripts and create automation around the instances. The multipass commands stop, start, restart, suspend, and delete are self-explanatory. You can perform those operations on named instances or use --all for all instances.

The multipass recover command is for recovering deleted instances, and purge cleans up after the deleted instances. The multipass commands take some other options, too, and you could dump the detailed info about any command with multipass help <Command>.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs

Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>


		<div class=