Day 65 of #100DaysOfLearning
Shinya Yanagihara
Developer Productivity Specialist - Global Black Belt @ Microsoft
The cloud environment is very convenient, but sometimes you still want to use a lightweight virtual machine environment on your local PC, right?
In fact, we are using Windows Subsystem for Linux 2 (WSL2), but it is sort of a substitute for cygwin. In other words, I use it as a Windows shell, so I decided to use Multipass because I wanted to use a virtual environment unlike that.
What is Multipass?
Multipass is a virtual machine (VM) manager developed by Canonical. It enables developers to easily create, manage, and launch lightweight virtual machines on their local machines, cloud environments, or Kubernetes clusters. Multipass is designed to provide a fast and convenient way to set up isolated development environments for testing, experimentation, and software development.
Some key features of Multipass:
- Fast Provisioning: Multipass allows for quick provisioning of virtual machines, with minimal overhead and setup time.
- Lightweight VMs: Multipass creates lightweight virtual machines that consume fewer system resources, making them ideal for development and testing purposes.
- Ubuntu-Based Images: By default, Multipass uses Ubuntu-based images for creating virtual machines, providing developers with a familiar environment and access to the Ubuntu package repositories.
- Command-Line Interface (CLI): Multipass offers a command-line interface (CLI) for managing virtual machines, enabling users to create, start, stop, delete, and manage VMs using simple commands.
- Integration with Cloud and Kubernetes: Multipass can be integrated with cloud platforms such as AWS, Azure, and Google Cloud Platform (GCP), as well as Kubernetes clusters, allowing users to deploy and manage VMs across different environments seamlessly.
- Cross-Platform Compatibility: Multipass is available for multiple operating systems, including Linux, macOS, and Windows, ensuring broad compatibility and ease of use across different development environments.
- Snap Package: Multipass is distributed as a snap package, making it easy to install, update, and manage on supported Linux distributions.
The differences between Multipass and WSL2
While both Multipass and WSL2 serve similar purposes of enabling Linux development on non-Linux platforms, they have different approaches and strengths. Multipass provides lightweight, isolated virtual machines for development, while WSL2 offers seamless integration between Windows and Linux environments. The choice between the two depends on the specific requirements and preferences of the developer.
Architecture
- Multipass: Multipass is a lightweight virtual machine manager that creates and manages virtual machines running Ubuntu or other Linux distributions. It uses hypervisor technology (such as Hyper-V on Windows, HyperKit on macOS, and KVM on Linux) to run these VMs.
- WSL2: Windows Subsystem for Linux 2 (WSL2) is a compatibility layer for running Linux binary executables natively on Windows 10 and Windows Server 2019. It does this by using a lightweight virtual machine running a Linux kernel, integrated tightly with the Windows operating system.
Integration with Host OS
- Multipass: Multipass runs virtual machines independently from the host operating system. It provides a clean separation between the host and guest environments, allowing for more isolated development environments.
- WSL2: WSL2 integrates the Linux kernel with the Windows host operating system, enabling seamless interoperability between Windows and Linux applications. It allows users to run Linux commands and tools directly from the Windows command line (CMD) or PowerShell.
Target Audience
- Multipass: Multipass is primarily targeted at developers who require lightweight, isolated development environments for testing, experimentation, and software development. It is well-suited for developers working on cross-platform projects or those who prefer using virtual machines for development.
- WSL2: WSL2 is aimed at developers who want to leverage the power of Linux tools and utilities while maintaining the familiarity of the Windows operating system. It is particularly useful for developers who need to work with Linux-based development tools, libraries, and frameworks on a Windows machine.
Performance and Resource Usage
- Multipass: Multipass creates lightweight virtual machines that consume minimal system resources. Each VM runs independently, allowing for efficient resource utilization and isolation.
- WSL2: WSL2 offers improved performance and resource usage compared to its predecessor (WSL1) by running a full Linux kernel in a lightweight virtual machine. It provides native-like performance for Linux applications running on Windows, with low overhead and fast startup times.
Choosing between Multipass and WSL2
Choose Multipass if you need lightweight, isolated virtual machines for cross-platform development, and prefer managing VMs independently from the host OS. Opt for WSL2 if you want seamless integration between Windows and Linux environments, with native-like performance and interoperability. Both tools offer unique benefits and can enhance your development workflow, so consider your requirements and preferences when selecting the best option for your needs.
Use Multipass if
- Isolated Development Environments: You require lightweight, isolated development environments for testing, experimentation, or software development.
- Cross-Platform Development: You work on cross-platform projects and need consistent development environments across different operating systems (Windows, macOS, or Linux).
- Virtual Machine Management: You prefer managing virtual machines independently from the host operating system and want full control over VM creation, configuration, and deletion.
- Linux-Based Development: You prefer using Linux-based tools, libraries, and development environments, such as those provided by Ubuntu or other Linux distributions.
- Minimal Resource Usage: You need virtual machines that consume minimal system resources and provide efficient resource utilization and isolation.
Use WSL2 if
- Integrated Windows-Linux Experience: You want to seamlessly integrate Linux development tools and utilities with the Windows operating system, allowing for native-like performance and interoperability.
- Windows-Exclusive Tools: You require access to Windows-exclusive development tools, applications, or workflows while still benefiting from Linux-based development environments.
- Command-Line Integration: You prefer running Linux commands and tools directly from the Windows command line (CMD) or PowerShell, without the need for a separate virtual machine management layer.
- Performance and Compatibility: You prioritize performance and compatibility with Windows applications, with WSL2 providing improved performance and tighter integration compared to WSL1.
领英推è
How to Install Multipass (in Windows)
> winget install Canonical.Multipass
Found Multipass [Canonical.Multipass] Version 1.13.1
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://github.com/canonical/multipass/releases/download/v1.13.1/multipass-1.13.1+win-win64.exe
██████████████████████████████ 28.9 MB / 28.9 MB
Successfully verified installer hash
Starting package install...
Successfully installed
How to Use Multipass
Show version details
> multipass version
multipass 1.13.1+win
multipassd 1.13.1+win
Display available images to create instances from
> multipass find
Image Aliases Version Description
core core16 20200818 Ubuntu Core 16
core18 20211124 Ubuntu Core 18
core20 20230119 Ubuntu Core 20
core22 20230717 Ubuntu Core 22
20.04 focal 20240223 Ubuntu 20.04 LTS
22.04 jammy,lts 20240223 Ubuntu 22.04 LTS
23.10 mantic 20240209 Ubuntu 23.10
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
Blueprint Aliases Version Description
anbox-cloud-appliance latest Anbox Cloud Appliance
charm-dev latest A development and testing environment for charmers
docker 0.4 A Docker environment with Portainer and related tools
jellyfin latest Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media.
minikube latest minikube is local Kubernetes
ros-noetic 0.1 A development and testing environment for ROS Noetic.
ros2-humble 0.1 A development and testing environment for ROS 2 Humble.
Create and start an Ubuntu instance (using Default configuration)
- CPU Core: 1 (-c/--cpus) [Minimum: 1, default: 1]
- Memory: 1G (-m/--memory) [Minimum: 512M, default: 5G]
- Disk: 5G (-d/--disk) [Minimum: 512M, default: 5G]
> multipass launch --name primary
Launched: primary
Skipping mount due to disabled mounts feature
Display information about instances or snapshots
> multipass info primary
Name: primary
State: Running
Snapshots: 0
IPv4: 172.26.62.180
Release: Ubuntu 22.04.4 LTS
Image hash: 3f48ed24115b (Ubuntu 22.04 LTS)
CPU(s): 1
Load: 0.02 0.06 0.03
Disk usage: 1.6GiB out of 4.8GiB
Memory usage: 197.5MiB out of 892.2MiB
Mounts: --
Open a shell on a running instance
> multipass shell primary
Welcome to Ubuntu 22.04.4 LTS (GNU/Linux 5.15.0-97-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of Sat Feb 24 14:37:51 JST 2024
System load: 0.0 Processes: 89
Usage of /: 34.3% of 4.67GB Users logged in: 0
Memory usage: 25% IPv4 address for eth0: 172.26.62.180
Swap usage: 0%
Expanded Security Maintenance for Applications is not enabled.
0 updates can be applied immediately.
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
ubuntu@primary:~$
Stop running instances
> multipass stop primary
> multipass list
Name State IPv4 Image
primary Stopped -- Ubuntu 22.04 LTS
Delete instances and snapshots
> multipass delete primary
> multipass list
Name State IPv4 Image
primary Deleted -- Ubuntu 22.04 LTS
Purge all deleted instances permanently
> multipass purge
> multipass list
No instances found.
Problem solving is my thing
10 个月very good info's thank you