Freelancing for Pale Blue

Looking for flexible work opportunities that fit your schedule?


Spin up command-line Ubuntu VMs in (almost) seconds

Infra Mar 23, 2024

Sometimes, you need a clean and disposable Linux environment to test configuration changes, try out a new tool, or simply isolate your experiments from your main system. There's a lightning-fast and easy way to launch Ubuntu command-line virtual machines (VMs) on Windows, macOS, or even Linux.

This is a super quick primer on how you can get started quickly. In less than 10 minutes you can have your command line Ubuntu VM.

What is Multipass?

Developed by Canonical (the company behind Ubuntu), Multipass provides a streamlined way to manage Ubuntu VMs. With a single command, you can spin up a fresh Ubuntu instance, perfect for those quick testing scenarios.

Multipass VMs have a relatively small footprint, conserving your system resources.

Quick start

Firstly, head to the Multipass website and follow the installation instructions for your operating system.

Launch your first VM

multipass launch 

That's it. This command downloads the Ubuntu image and boots up a VM. As soon the latest Ubuntu LTS (long-term support) image is downloaded and deployed, you will be entered into the shell.

Every time you run this command a new VM is created.

Launch an existing VM

mutlipass shell <vm-name>

For follow-up runs, use this command to launch into the shell of an existing VM. If you only have 1 VM, you can omit vm-name.

Mount a host directory

multipass mount <source-path-on-host> <vm-name>:<mount-point-in-vm>

The default name for the vm-name is primary.

Start/Stop/Delete/List VMs

multipass delete <vm-name> 
multipass start <vm-name>
multipass stop <vm-name>
multipass list

Quite self-explanatory commands. With these, you can manage the VMs in your system.

Modify VM resources

Almost certainly, you will need to modify the resources of your VMs at some point. Fear not, you can do it quickly (documentation):

multipass set local.<vm-name>.cpus=4
multipass set local.<vm-name>.disk=60G
multipass set local.<vm-name>.memory=7G

Alternatives for VMs with GUI

If you require a full-fledged Linux VM with a graphical desktop environment:

  • UTM (macOS): A streamlined VM solution tailored for macOS. Highly recommended, really polished, and easy to use.
  • VirtualBox (Windows, macOS, Linux): A powerful and versatile virtualization platform with more extensive configuration options.

Give Multipass a try the next time you need a quick and isolated Linux environment. Its simplicity and speed will make it an indispensable tool in your development workflow.

Happy hacking!

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.