How to Use Ubuntu multipass to Orchestrate Lightweight Virtual Machine Fleets

The Heavyweight VM Dilemma

When a Linux software engineer needs to test a complex application—such as a multi-node Kubernetes cluster or a custom kernel module—they cannot test it directly on their primary Ubuntu workstation. If the kernel module crashes, it takes down their entire machine. Historically, developers solved this by deploying full virtual machines using VirtualBox or VMware Workstation. However, these tools are massive, GUI-dependent, and incredibly slow. Booting a VirtualBox VM, clicking through the Ubuntu ISO installer, and configuring SSH keys takes 20 minutes.

While Docker containers boot instantly, they are mathematically restricted. A Docker container shares the host’s kernel. If you need to test a specific kernel modification, or if you need to simulate a true, distinct Linux operating system (with its own systemd init process), Docker is useless.

To solve the gap between the speed of containers and the true isolation of virtual machines, Canonical engineered Multipass. Multipass is a brilliant, lightweight command-line orchestrator that interfaces directly with native hypervisors (like KVM on Linux, Hyper-V on Windows, or Hypervisor.framework on macOS). It allows a developer to request a pristine, fully configured Ubuntu virtual machine with a single command. In seconds, Multipass downloads the cloud image, injects SSH keys, mounts shared folders, and boots a true VM, providing instant, disposable cloud-like infrastructure directly on a local laptop.

Step 1: Installing the Multipass Daemon

Multipass is developed by Canonical (the creators of Ubuntu) and is distributed primarily as a Snap package, guaranteeing it is securely confined and automatically updated.

Install Multipass on your Ubuntu workstation:

sudo snap install multipass

Once installed, the Multipass daemon runs continuously in the background, communicating with the libvirt/qemu hypervisor stack. You do not need to configure complex XML libvirt files; Multipass abstracts the entire virtualization layer.

Step 2: The Instant Provisioning Engine

Suppose you need a pristine Ubuntu 22.04 server to test a risky database migration script.

Instead of downloading an ISO, you simply command Multipass to launch it. You can define the mathematical limits of the VM (CPU, RAM, and Disk) directly in the command.

multipass launch 22.04 --name db-test-node --cpus 2 --memory 4G --disk 20G

The exact millisecond you execute this command, Multipass performs several autonomous actions:

  1. It reaches out to Canonical’s image servers and downloads the highly optimized, minimal Ubuntu 22.04 Cloud Image (the exact same image used by AWS EC2).
  2. It caches the image locally so subsequent launches take only seconds.
  3. It uses cloud-init to inject a default user (ubuntu) and automatically generates and installs an SSH keypair.
  4. It boots the VM and requests an IP address via a hidden NAT bridge.

Within 15 seconds, the terminal returns control. You now possess a fully functional, 2-core, 4GB RAM virtual server.

Step 3: Seamless Integration (Shell and Execution)

To interact with the VM, you do not need to manually figure out its IP address or manage SSH keys. Multipass handles the cryptographic tunneling automatically.

To drop directly into a root-level shell inside the VM:

multipass shell db-test-node

Your prompt changes to ubuntu@db-test-node:~$. You are now inside a completely isolated kernel environment.

Furthermore, you can execute commands inside the VM without opening an interactive shell. This is critical for scripting. If you want to run an apt update inside the VM from your host machine’s bash script:

multipass exec db-test-node -- sudo apt update -y

Step 4: Bridging the Filesystem (Mounting)

When developing code, you write the code on your host machine (using VS Code or IntelliJ), but you need to execute it inside the isolated Multipass VM. Manually copying files back and forth using scp is highly inefficient.

Multipass provides an autonomous filesystem bridge.

To mathematically mount your local ~/Projects/database_migration folder directly into the VM at /var/www/migration, execute:

multipass mount ~/Projects/database_migration db-test-node:/var/www/migration

This is a live, bidirectional mount. If you save a file in VS Code on your host machine, the exact millisecond you press Ctrl+S, the file is instantly updated inside the virtual machine’s /var/www/migration directory, allowing for real-time testing within the isolated hypervisor.

Step 5: Cloud-Init Orchestration (Automated Bootstrapping)

When deploying fleets of VMs, manually logging into each one to install software (like Nginx or Docker) defeats the purpose of automation.

Multipass natively understands Cloud-Init YAML directives. You can write a config.yaml file on your host machine that explicitly dictates the mathematical state the VM must achieve upon booting.

#cloud-config
packages:
  - docker.io
  - nginx
runcmd:
  - systemctl start docker
  - systemctl enable docker

When you launch the VM, you pass the YAML file into the deployment engine:

multipass launch --name web-fleet-01 --cloud-init config.yaml

The VM boots, instantly reads the YAML file, installs Docker, installs Nginx, and starts the services autonomously. You have successfully replicated enterprise cloud orchestration directly on your local workstation.

Step 6: The Disposable Lifecycle

When the database migration test is complete, the VM becomes dead weight. Unlike VirtualBox, where deleting a VM leaves scattered .vdi files across your hard drive, Multipass obliterates the environment surgically.

multipass delete db-test-node
multipass purge

The purge command permanently destroys the virtual hard drive and releases the RAM back to your host operating system, ensuring perfect cryptographic and storage hygiene.

Conclusion

Relying on heavyweight, GUI-driven virtualization platforms introduces massive friction into the Linux development lifecycle. By deploying Multipass, Ubuntu engineers bridge the gap between the speed of containers and the absolute kernel isolation of virtual machines. The ability to provision pristine cloud images in seconds, orchestrate automated bootstrapping via Cloud-Init, and seamlessly mount live filesystems transforms any local workstation into a highly agile, software-defined micro-cloud.

RELATED POSTS

  • How to Use Ubuntu AppArmor to Restrict Docker Container Capabilities
  • How to Secure an Nginx Web Server with Let’s Encrypt and UFW on Ubuntu
  • How to Install and Configure the Proxmox Backup Server (PBS) Client on Debian
  • How to Install and Configure the Postfix Mail Server on Ubuntu
  • How to Join an Ubuntu Linux Machine to a Windows Active Directory Domain using SSSD
  • Get the best tech tips delivered straight to your inbox.

    Join thousands of readers mastering Apple, Google, Microsoft, and Linux.