// Module included in the following assemblies:
//
// * virt/virtual_machines/creating_vm/virt-creating-vms-from-instance-types.adoc

:_mod-docs-content-type: PROCEDURE
[id="virt-change-vm-instance-type-cli_{context}"]
= Changing the instance type of a VM by using the CLI

[role="_abstract"]
To change the instance type of a VM, change the `name` field in the VM spec. This triggers the update logic, which ensures that a new, immutable controller revision snapshot is taken of the new resource configuration.

.Prerequisites

* You have installed the {oc-first}.
* You created the VM by using an instance type, or have administrator privileges for the VM that you want to modify.

.Procedure

. Stop the VM.

. Run the following command, and replace `<vm_name>` with the name of your VM, and `<new_instancetype>` with the name of the instance type you want to change to:
+
[source,terminal]
----
$ oc patch vm/<vm_name> --type merge -p '{"spec":{"instancetype":{"name": "<new_instancetype>"}}}'
----

.Verification

* Check the controller revision reference in the updated VM `status` field. Run the following command and verify that the revision name is updated in the output:
+
[source,terminal]
----
$ oc get vms/<vm_name> -o json | jq .status.instancetypeRef
----
+
Example output:
+
[source,terminal]
----
{
  "controllerRevisionRef": {
    "name": "vm-cirros-csmall-csmall-3e86e367-9cd7-4426-9507-b14c27a08671-2"
  },
  "kind": "VirtualMachineInstancetype",
  "name": "csmall"
}
----

* Optional: Check that the VM instance is running the new configuration defined in the latest controller revision. For example, if you updated the instance type to use 2 vCPUs instead of 1, run the following command and check the output:
+
[source,terminal]
----
$ oc get vmi/<vm_name> -o json | jq .spec.domain.cpu
----
+
Example output that verifies that the revision uses 2 vCPUs:
+
[source,terminal]
----
{
  "cores": 1,
  "model": "host-model",
  "sockets": 2,
  "threads": 1
}
----
