Virtual Machine Operations
Virtual Machine Creation
Minimal requirements to create a new VM
- An image from which the VM should be created
- A flavor defining the size of the virtual machine
- Select the network
- It is possible to select the resource by its name or ID
Example
openstack server create \
--image jammy \
--flavor cpu1-ram2-disk16 \
--network network-test \
vm-test
Expected result
+--------------------------------------+------------------------------------------------------------------+
| Field | Value |
+--------------------------------------+------------------------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-STS:power_state | NOSTATE |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | None |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | |
| adminPass | 5RQbwZiZr8Bb |
| config_drive | |
| created | 2026-01-07T11:25:11Z |
| flavor | cpu1-ram2-disk16 (10) |
| hostId | |
| id | 4d0ea8bb-3993-4605-bf74-2006bde692d4 |
| image | jammy (6810cc80-0581-4521-b7b7-6cc850f7af3f) |
| key_name | None |
| name | vm-test |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| project_id | 244692efa9c44ceca00ca9ab7be6f8c2 |
| properties | |
| security_groups | name='default' |
| status | BUILD |
| updated | 2026-01-07T11:25:10Z |
| user_id | c7f705789866dcdd367146d138f540654e2b6b42d5c9b67ee7c3b46f6cca5224 |
+--------------------------------------+------------------------------------------------------------------+
Note: This method not create a volume attached
Example with volumen attached
openstack server create \
--image jammy \
--flavor cpu1-ram2-disk16 \
--boot-from-volume 16 \
--network network-test \
vm-test
Virtual Machine Resize
If the flavor of a virtual machine needs to be changed, such as adding more memory or vCPUs, this can be done using the resize operation. Using resize, you can select a new flavor for your virtual machine. This is an offline operation, meaning that the virtual machine will be shutdown, configured with the new flavor properties and booted again. Depending on the size of the virtual machine size, this operation can take several minutes.
It's only recommended to increase the size of the virtual machine, ie. from a smaller to a larger flavor.
Resizing a VM from the command line
Select a new flavor for the available flavors
openstack flavor list
+--------------------------------------+--------------------+-------+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+--------------------------------------+--------------------+-------+------+-----------+-------+-----------+
| 10 | cpu1-ram2-disk16 | 2048 | 16 | 0 | 1 | True |
| 25 | cpu2-ram8-disk32 | 8192 | 32 | 0 | 2 | True |
| 44 | cpu4-ram16-disk32 | 16384 | 32 | 0 | 4 | True |
| 59c8e933-109e-4217-92e6-33b5d324ec62 | cpu2-ram4-disk32 | 4096 | 32 | 0 | 2 | True |
| 60bd8eaf-fece-4b9a-8124-d5f54c931ff7 | cpu4-ram8-disk32 | 8192 | 32 | 0 | 4 | True |
| 63 | cpu8-ram16-disk32 | 16384 | 32 | 0 | 8 | True |
| fda74ecb-e382-4035-abee-3229470c96c1 | cpu16-ram32-disk32 | 32768 | 32 | 0 | 16 | True |
+--------------------------------------+--------------------+-------+------+-----------+-------+-----------+
To resize the virtual machine, run:
openstack server resize --flavor cpu2-ram8-disk32 vm-test
After one minute, execute this command to confirm the resize
openstack server resize confirm vm-test
check the result
openstack server show vm-test | grep flavor
Virtual Machine Deletion
VMs can be deleted using either the OpenStack dashboard or via the openstack server delete command.
- This will immediately terminate the instance, delete all content of the virtual machine and erase the disk. This operation is not recoverable. unless we haven't deleted the instance volume
openstack delete vm-test
Redeploy instance from volume
firts , we need the id or name of the volume
openstack volume list
+--------------------------------------+---------------------------------+-----------+------+----------------------------------------------------------------+
| ID | Name | Status | Size | Attached to |
+--------------------------------------+---------------------------------+-----------+------+----------------------------------------------------------------+
| fdb9e3bd-ea5e-4656-92ab-9b7f5e7c3b20 | | available | 16 | |
Redeploy the instance
openstack server create \
--volume fdb9e3bd-ea5e-4656-92ab-9b7f5e7c3b20 \
--flavor cpu1-ram2-disk16 \
--network network-test \
vm-test