DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Ansible and the Pre-Container Arts
  • Keep Your Application Secrets Secret
  • Have You Heard About Cloud Native Buildpacks?
  • Mastering Cloud Containerization: A Step-by-Step Guide to Deploying Containers in the Cloud

Trending

  • *You* Can Shape Trend Reports: Join DZone's Software Supply Chain Security Research
  • AI-Based Threat Detection in Cloud Security
  • Performance Optimization Techniques for Snowflake on AWS
  • The Modern Data Stack Is Overrated — Here’s What Works
  1. DZone
  2. Software Design and Architecture
  3. Containers
  4. A Comprehensive Guide to Multipass: Simplifying Virtual Machine Management

A Comprehensive Guide to Multipass: Simplifying Virtual Machine Management

In this comprehensive tutorial, we will walk you through the process of setting up a Docker Swarm cluster and deploying Docker containers within it.

By 
Aditya Bhuyan user avatar
Aditya Bhuyan
·
Jan. 12, 24 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
4.0K Views

Join the DZone community and get the full member experience.

Join For Free

We now manage and deploy computing resources in completely new ways thanks to virtualization. The ability to create and manage virtual machines (VMs) is essential for anyone interested in technology, whether they are programmers, system administrators, or just tech enthusiasts. A simple method for creating and managing virtual machines on your local machine is offered by Multipass, an open-source program created by Canonical. This comprehensive guide will provide in-depth coverage of Multipass’ installation, use, and numerous advanced features.

Introduction To Multipass

What Is Multipass?

An easy-to-use, cross-platform command-line tool called Multipass makes it possible for you to set up and control Linux virtual machines on your local system. Multipass, created by Canonical, the organization responsible for Ubuntu, makes use of cloud-init, cloud images, and snap packages to offer a seamless environment for running and testing applications in isolated environments.

Why Use Multipass?

Multipass offers several advantages for developers, system administrators, and anyone who needs to work with virtual machines:

  • Simplicity: Multipass is designed to be user-friendly and straightforward, making it an excellent choice for those new to virtualization.
  • Resource efficiency: VMs created with Multipass are lightweight and consume minimal system resources, making them ideal for development and testing purposes.
  • Cross-platform: Multipass supports Windows, macOS, and various Linux distributions, ensuring compatibility with a wide range of systems.
  • Cloud integration: Multipass seamlessly integrates with cloud services, allowing you to bridge the gap between local development and cloud deployment.
  • Isolation: Each VM is isolated from your host system, providing a safe environment for experimentation without affecting your local machine.

Installation

Installing Multipass

Before you can start using Multipass, you need to install it on your system. Here are the steps for installing Multipass on different platforms:

Linux (Ubuntu/Debian):

 
sudo snap install multipass --classic


Linux (Other Distributions):

 
# Install snapd first if not already installed

sudo apt update

sudo apt install snapd

sudo snap install multipass --classic


macOS:

Download the macOS installer from the Multipass website and follow the installation instructions.

Windows:

Download the Windows installer from the Multipass website and follow the installation instructions.

Supported Platforms

Multipass supports a wide range of host operating systems, including:

  • Linux (various distributions)
  • macOS
  • Windows

Ensure that your system meets the minimum requirements for running Multipass, such as having sufficient RAM and disk space available.

Creating Your First VM

Launching a VM

To create your first VM with Multipass, open your terminal or command prompt and run the following command:

 
multipass launch


This command will create a VM with default settings and a random name, using the latest Ubuntu LTS (Long Term Support) release as the base image.

Choosing an OS Image

You can specify a different OS image when creating a VM. For example, to create a VM with Ubuntu 20.04:

 
multipass launch ubuntu:20.04


Multipass offers various images, including different Ubuntu versions and other Linux distributions. You can also use custom images if needed.

Basic VM Operations

Once your VM is created, you can perform basic operations using Multipass:

Starting a VM

To start a VM, use the start command. Replace with the name of your VM.

 
multipass start <vm-name>


Stopping a VM

Use the stop command to stop a running VM.

 
multipass stop <vm-name>


Deleting a VM

To delete a VM, use the delete command. Be cautious, as this action is irreversible.

 
multipass delete <vm-name>


Working With VMs

Accessing the VM

You can access the terminal of your VM using the exec command. Replace with your VM’s name:

 
multipass exec <vm-name> -- /bin/bash


This command opens a shell session within the VM, allowing you to interact with it.

Transferring Files

Using the transfer command, you can transfer files between your host system and the VM. For example, to copy a file from your local machine to the VM:

 
multipass transfer /path/to/local/file <vm-name>:/path/in/vm


To copy a file from the VM to your local machine:

 
multipass transfer <vm-name>:/path/in/vm /path/to/local/directory


Inspecting VM Information

To view information about your VM, including its IP address and available resources, use the info command:

 
multipass info <vm-name>


Copying and Pasting Text

Multipass allows you to copy and paste text between your host machine and the VM. You can copy text from your host machine’s clipboard and paste it into the VM’s terminal and vice versa.

Configuring VMs

Changing VM Resources

Using the set command, you can adjust the resources allocated to a VM, such as CPU cores and memory. For example, to allocate 2 CPU cores and 4 GB of RAM to your VM:

 
ltipass set <vm-name> --cpus 2 --mem 4G


Adding Storage

Multipass allows you to add additional storage to your VMs using the storage command. This can be useful for expanding the available disk space when needed.

Configuring Networking

Multipass provides various networking options to configure how your VM interacts with the host system and the external network. You can specify custom network configurations or use the default settings.

Managing Multiple VMs

Creating Multiple VMs

You can create multiple VMs with different configurations. Simply specify a unique name for each VM during the creation process:

 
multipass launch --name vm1

multipass launch --name vm2


Listing VMs

To list all the VMs you’ve created, use the list command:

 
multipass list


Deleting VMs

When you no longer need a VM, you can delete it to free up resources:

 
multipass delete <vm-name>


Customizing VMs

Installing Software

You can install software packages in your VMs using standard package managers like apt or yum. For example, to install nginx on an Ubuntu-based VM:

 
multipass exec <vm-name> -- sudo apt-get install nginx


Running Scripts

You can execute scripts within your VM to automate tasks. Create a script on your local machine and copy it to the VM using multipass transfer. Then, use multipass exec to run the script in the VM.

Configuring SSH Keys

To enhance security, you can configure SSH keys for secure remote access to your VMs. Generate SSH keys on your local machine and transfer the public key to the VM. Then, you can SSH into the VM using your private key.

Snapshots and Cloning

Taking Snapshots

Multipass allows you to take snapshots of your VMs at specific points in time. Snapshots capture the VM’s state, including its file system, memory, and running processes. To create a snapshot:

 
multipass snapshot <vm-name> snapshot-name


Cloning VMs from Snapshots

You can create new VMs by cloning existing snapshots. This is useful for quickly reproducing VMs with specific configurations and software installed:

 
multipass launch --name new-vm-name --snapshot snapshot-name


Restoring from Snapshots

To restore a VM to a previous snapshot, stop the VM and use the restore command:

 
multipass stop <vm-name>

multipass restore <vm-name> snapshot-name

multipass start <vm-name>


Integration With Cloud Services

  • Connecting to cloud services: Multipass can be integrated with cloud services such as AWS, Azure, and GCP. This allows you to move workloads between your local environment and the cloud seamlessly.
  • Cloud-init support: Multipass supports cloud-init, a widely-used cloud initialization tool. You can provide cloud-init configuration to your VMs to automate various tasks during initialization.

Troubleshooting and Tips

  • Common issues: If you encounter any issues while using Multipass, consult the official documentation and community resources for troubleshooting guidance.
  • Useful tips and tricks
    • Regularly update Multipass to benefit from the latest features and bug fixes.
    • Use snapshots to create checkpoints before making significant changes to your VM.
    • Keep track of the resources allocated to your VMs to avoid performance issues.

Advanced Usage

  • Building custom images: Advanced users can create custom images tailored to their specific needs. This involves creating a base image, installing software, configuring settings, and then using Multipass to launch VMs based on the custom image.
  • Managing Multipass instances remotely: You can manage Multipass instances on remote servers using SSH. This enables you to control VMs on other machines from your local terminal.
  • Multipass plugins: Explore available Multipass plugins to extend their functionality and integrate with additional cloud services or tools.

Conclusion

From installation to advanced usage, we have covered everything you need to know about Multipass in this extensive guide. Whether you are a developer looking to test software or a system administrator working with intricate configurations, Multipass is a strong and adaptable tool for managing virtual machines. Your virtualization workflow can be streamlined, and your productivity can be increased with Multipass. Cheers to virtualization!

Cloud ubuntu Virtual Machine Docker (software)

Published at DZone with permission of Aditya Bhuyan. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Ansible and the Pre-Container Arts
  • Keep Your Application Secrets Secret
  • Have You Heard About Cloud Native Buildpacks?
  • Mastering Cloud Containerization: A Step-by-Step Guide to Deploying Containers in the Cloud

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!