How to modify an instance

See also: Instance

This document shows further ways to customize an instance outside of the launch command, via settings.

Contents:

Set the CPU, RAM or disk of an instance

See also: local.<instance-name>.(cpus|disk|memory)

While instance properties can be determined at launch, some of them can be updated after the instance has been created. Specifically, an instance’s memory, disk space, and the number of its CPUs are exposed via daemon settings: local.<instance-name>.(cpus|disk|memory).

To modify one of this properties, first stop the instance and then issue the set command. For example:

$ multipass stop handsome-ling
$ multipass set local.handsome-ling.cpus=4
$ multipass set local.handsome-ling.disk=60G
$ multipass set local.handsome-ling.memory=7G

When increasing the disk size of an instance, the partition may not expand automatically to use the new available space. This usually happens if the partition was already full when trying to increase the disk size. In such cases, the partition must be expanded manually, as follows:

$ multipass shell handsome-ling
ubuntu@handsome-ling$ sudo parted /dev/sda resizepart 1 100%
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 4194304 blocks) or continue with the current setting?
Fix/Ignore? fix
Partition number? 1
Warning: Partition /dev/sda1 is being used. Are you sure you want to continue?
Yes/No? yes
ubuntu@handsome-ling$ sudo resize2fs /dev/sda1

These properties can be consulted with the get command. Instances do not have to be stopped for that. For example:

$ multipass get local.handsome-ling.cpus
4
$ multipass get local.handsome-ling.disk
60.0GiB
$ multipass get local.handsome-ling.memory
7.0GiB

Only properties of stopped, non-deleted instances can be updated, but all instances can have their properties fetched. Their keys can be obtained with multipass get --keys. Yet, trying to update an instance that is running, suspended, or deleted, results in an error.

Modifying instance settings is not supported when using the hyperkit driver, which has been deprecated in favor of the qemu. The qemu and virtualbox drivers on Intel macOS do support instance modification.

Set the status of an instance to primary

See also: client.primary-name

This section demonstrates how to set the status of an instance to primary. This is convenient because it makes this instance the default argument for several commands, such as shell , start , stop , restart , and suspend and also automatically mounts our $HOME directory in the instance.

To grant a regular instance the primary status, assign its name to the client.primary-name:

$ multipass set client.primary-name=<instance name>

This setting allows transferring primary status among instances. The primary name can be configured independently of whether instances with the old and new names exist. If they do, they lose and gain primary status accordingly.

This provides a means of (de)selecting an existing instance as primary. An example is show below:

# Assign the primary status to an instance called 'first':
$ multipass set client.primary-name=first
# Now this instance is picked up automatically by 'multipass start'
# The primary instance also automatically mounts the user's home directory into a directory called 'Home'
$ multipass start
Launched: first
Mounted '/home/ubuntu' into 'first:Home'
# Stop the primary instance
$ multipass stop
$ multipass launch --name second
Launched: second
# Change the primary instance to an existing instance
$ multipass set client.primary-name=second
# Now this instance is used by default by the commands
$ multipass suspend
# When listing all instances, the primary one is displayed first
$ multipass list
Name                    State             IPv4             Image
second                  Suspended         --               Ubuntu 18.04 LTS
first                   Stopped           --               Ubuntu 18.04 LTS

Last updated 2 months ago.