Rate This Document
Findability
Accuracy
Completeness
Readability

Creating a VM

It is recommended that block storage be used as the backend storage. It is not recommended that images be directly used to create VMs.

You can create a VM in either of the following methods:

Method 1

  1. Create a system volume based on the image.
    cinder create $disk_size --image $image_id --name $volume_name
    • Modify the following parameters as required:
      • Replace disk_size with the created drive size, in GB.
      • Replace image_id with the ID of the system image. You can run the openstack image list command to query the ID.
      • Replace volume_name with the name of the created system volume.
    • Record the ID of the created system volume for future use. You can run the cinder list command to query the ID.
    • The value of disk_size cannot be less than the virtual drive size of the image. Otherwise, the VM fails to be created. You can run the following command to query the virtual drive size of the image. Replace openEuler-22.03-LTS-SP2-aarch64.qcow2 with the name of the image file you uploaded.
      qemu-img info openEuler-22.03-LTS-SP2-aarch64.qcow2
  2. Create a VM using the system volume.
    nova boot --nic net-name=$vm_net --flavor $flavor_id --boot-volume $volume_id $vm_name

    Modify the following parameters as required:

    • Replace vm_net with the network ID of the created VM. You can run the openstack network list command to query the ID.
    • Replace flavor_id with the ID of the created VM flavor type. You can run the nova flavor-list command to query the ID.
    • Replace volume_id with the ID of the system volume in 1. You can run the cinder list command to query the ID.
    • Replace vm_name with the name of the created VM.

Method 2

Run the following command to create a system volume and a VM.
nova boot --nic net-name=$vm_net --flavor $flavor_id --block-device source=image,dest=volume,id=$image_id ,bootindex=0,size=$disk_size $vm_name

Modify the following parameters as required:

  • Replace vm_net with the network ID of the created VM. You can run the openstack network list command to query the ID.
  • Replace flavor_id with the ID of the created VM flavor type. You can run the nova flavor-list command to query the ID.
  • Replace image_id with the ID of the system image. You can run the openstack image list command to query the ID.
  • Replace disk_size with the created drive size, in GB.
  • Replace vm_name with the name of the created VM.
  • The value of disk_size cannot be less than the virtual drive size of the image. Otherwise, the VM fails to be created. You can run the following command to query the virtual drive size of the image. Replace openEuler-22.03-LTS-SP2-aarch64.qcow2 with the name of the image file you uploaded.
    qemu-img info openEuler-22.03-LTS-SP2-aarch64.qcow2