Changing virtual machine resources

You can change amount of CPU and RAM resources used by a virtual machine by applying another flavor to it. To be able to resize a running VM, you need to enable CPU and RAM hot plug for it first. You can change the hot plug settings for both new and existing VMs.

A running virtual machine has a resize limit, which defines the maximum number of vCPUs and the maximum amount of RAM you can allocate to the VM. The resize limit on vCPUs is static and equal to 64 for all VMs. The resize limit on RAM, on the contrary, is dynamic and depends on the amount of RAM a running VM is currently using. This limit is updated on a VM startup, and its values are listed in the table below.

Current RAM size, in GiB RAM size limit, in GiB
1-4 16
5-8 32
9-16 64
17-32 128
33-64 256
65-128 512
129-256 1024

For example, you can resize a running VM with a flavor that has 16 GiB to a flavor with 256 GiB in two iterations:

  1. Resize the VM to a flavor with 64 GiB.
  2. Restart the VM to update the RAM size limit.
  3. Resize the VM to a flavor with 256 GiB.

Limitations

Prerequisites

  • Before changing a flavor, ensure that the node hosting the VM has at least as much free CPU and RAM resources as the new VM size. For example, to resize a VM to the large flavor, the host must have at least 4 vCPUs and 8 GiB of RAM free.
  • Before resizing a running VM, ensure that the guest operating system supports CPU and RAM hot plug (refer to Supported guest operating systems). Note that otherwise the guest operating system may become unstable after a resize. To increase CPU or RAM resources for such a guest operating system, you need to stop the virtual machine first.
  • Before resizing a running VM, ensure that the guest operating system has the latest updates installed.

To enable or disable CPU and RAM hot plug for a virtual machine

Admin panel

  1. On the Compute > Virtual machines > Virtual machines screen, ensure that the required virtual machine in the "Shut down" state, and then click it.
  2. On the Overview tab, click the pencil icon in the CPU and RAM hot plug field.

  3. Select or clear the Enable hot plug check box, and then click the tick icon to save the changes.

With CPU and RAM hot plug enabled, you can change the flavor of a running VM.

Command-line interface

Use the following command:

vinfra service compute server set <server> {--allow-live-resize | --deny-live-resize}
--allow-live-resize
Allow online resize for the virtual machine.
--deny-live-resize
Deny online resize for the virtual machine.
<server>
Virtual machine ID or name

For example, to enable CPU and RAM hot plug for the virtual machine myvm, run:

# vinfra service compute server set myvm --allow-live-resize

To change the virtual machine flavor

Admin panel

  1. On the Compute > Virtual machines > Virtual machines screen, click the required virtual machine.
  2. On the Overview tab, click the pencil icon in the Flavor field.
  3. In the Flavor window, select a new flavor, and then click Done.

Command-line interface

Use the following command:

vinfra service compute server resize --flavor <flavor> <server>
--flavor <flavor>
Apply flavor with ID or name
<server>
Virtual machine ID or name

For example, to change the flavor of the virtual machine myvm to small, run:

# vinfra service compute server resize myvm --flavor small