How to modify an instance

See also: Instance, launch, set, Settings

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

Set the CPUs , RAM or disk space of an instance

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

You can set instance properties at launch time, but you can also update some of them 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

The disk size can only be increased.

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, you need to expand the partition manually. To do so, shell into the instance and run the following command:

sudo parted /dev/sda resizepart 1 100%

The system will guide you through the configuration steps:

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

When done, run sudo resize2fs /dev/sda1.

You can view these properties using the get command, without the need to stop instances. For example, multipass get local.handsome-ling.cpus returns the configured number of CPUs, which in our example is “4”.

You can only update the properties of Stopped, non-deleted instances. If you try to update an instance that is in Running, Suspended, or Deleted status you’ll incur an error.

On the other hand, it’s always possible to fetch properties for all instances. Use multipass get --keys to obtain their settings keys.

Modifying instance settings is not supported when using the Hyperkit driver, which has been deprecated in favor of QEMU. The QEMU and VirtualBox drivers on Intel-based macOS hosts 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 your $HOME directory into 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 instance’s 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.

Example

Assign the primary status to an instance called “first”:

multipass set client.primary-name=first

This instance is picked up automatically by multipass start. When you run this command, the primary instance also automatically mounts the user’s home directory into a directory called Home:

...
Launched: first
Mounted '/home/ubuntu' into 'first:Home'

Run multipass stop to stop the primary instance, and then launch another instance named “second”:

multipass launch --name second

Now, change the primary instance to the existing “second” instance:

multipass set client.primary-name=second

From now on, the “second” instance will be used as the primary instance, so for example it will be used by default when you run the command multipass suspend.

When listing instances, the primary one is displayed first. For example, if you run multipass list now, you’ll see:

Name                    State             IPv4             Image
second                  Suspended         --               Ubuntu 18.04 LTS
first                   Stopped           --               Ubuntu 18.04 LTS

Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.

4 Likes

I am running multipass 1.9.0 on Mac book Pro with Apple silicone.

Trying to update disk size and getting this error :

multipass set local.superior-chihuahua.disk=20G
set failed: Unrecognized settings key: ‘local.superior-chihuahua.disk’

Hi @garichd!

Sorry for the confusion. This document did not specify the Multipass version this will be in. It will be in the upcoming version 1.10 and is available only as a preview on Linux.

I’ve updated the documented to reflect this fact.

1 Like

Thanks for the reply @townsend
is there anyway I can use this feature earlier with specific patch , I noticed that this was released back in 2021 under build #2353, However I am not sure the way to get that build installed.!

My VM was installed with default settings and I am now running out of space, Its configured heavily and to redo the work will set me back weeks…! :frowning:

Hi @garichd,

It was actually merged into the main branch on April 22.

If you are brave adventurous enough, you can get an unsigned-but-built-by-ci package from https://multipass-ci.s3.amazonaws.com/ci3606/multipass-1.10.0-dev.607.ci3606%2Bg7799cf6d.mac-Darwin.pkg that has this feature. I don’t anticipate you having any major regressions with this development package, but of course it can happen.

2 Likes

Hi there… quick heads up… the link
See also: local.<instance-name>.(cpus|disk|memory)
is broken.

Cheers

I ran out of space so I resized with

multipass set local.charm-dev-2cpu-7g.disk=70G

That seemed to work:

$ sudo parted /dev/sda print free
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 75.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
        17.4kB  1049kB  1031kB  Free Space
14      1049kB  5243kB  4194kB                     bios_grub
15      5243kB  116MB   111MB   fat32              boot, esp
 1      116MB   53.7GB  53.6GB  ext4
        53.7GB  75.2GB  21.5GB  Free Space

At this point I wasn’t sure how to go about resizing the partition: sudo systemctl isolate rescue.target hangs. So I went on and resized it while it was mounted:

(parted) resizepart 1 75.2GB
Warning: Partition /dev/sda1 is being used. Are you sure you want to continue?
Yes/No? Yes

However, this change isn’t reflected in df -h, even after a reboot.
What am I missing here?

After I manually freed up some space and rebooted, df reflected the change. Interesting.

Hey @sed-i!

Glad you got it working! cloud-init will grow the partition to match the disk size automatically during boot. I suspect that something with cloud-init failed due to the lack of disk space.

That makes sense, thanks @townsend.

  • Do you mean there was no need to use parted, only (free some space and) reboot?
  • If using parted is still needed, shouldn’t we unmount first? How?

Hey @sed-i!

Do you mean there was no need to use parted, only (free some space and) reboot?

Yes, the growpart directive for cloud-init tells cloud-init to automatically grow the partition on boot to match the disk space. It basically does the parted for you.

1 Like

Hello,
The current document is incomplete with regards to resizing the disk size of a VM. AFTER the resizing, the partitions need to be updated from within the virtual machine itself, it seems. Here is a very nicely written guide which worked for me:
https://theko2fi.github.io/multipass/2023/08/18/expand-a-multipass-vm-disk-no-space-left-on-device.html

Hey, @vidimuswolf! Indeed, I can reproduce this and it is a problem. We’ll investigate the issue and see if we can come up with a fix. Thanks for reporting this!