Expanding virtual machine disks

You can increase the size of a virtual machine (VM) disk by expanding the persistent volume claim (PVC) of the disk.

If your storage provider does not support volume expansion, you can expand the available virtual storage of a VM by adding blank data volumes.

You cannot reduce the size of a VM disk.

Expanding a VM disk PVC

You can increase the size of a virtual machine (VM) disk by expanding the persistent volume claim (PVC) of the disk.

If the PVC uses the file system volume mode, the disk image file expands to the available size while reserving some space for file system overhead.

Procedure

  1. Edit the PersistentVolumeClaim manifest of the VM disk that you want to expand:

    1. $ oc edit pvc <pvc_name>
  2. Update the disk size:

    1. apiVersion: v1
    2. kind: PersistentVolumeClaim
    3. metadata:
    4. name: vm-disk-expand
    5. spec:
    6. accessModes:
    7. - ReadWriteMany
    8. resources:
    9. requests:
    10. storage: 3Gi (1)
    11. # ...
    1Specify the new disk size.

Additional resources for volume expansion

Expanding available virtual storage by adding blank data volumes

You can expand the available storage of a virtual machine (VM) by adding blank data volumes.

Prerequisites

  • You must have at least one persistent volume.

Procedure

  1. Create a DataVolume manifest as shown in the following example:

    Example DataVolume manifest

    1. apiVersion: cdi.kubevirt.io/v1beta1
    2. kind: DataVolume
    3. metadata:
    4. name: blank-image-datavolume
    5. spec:
    6. source:
    7. blank: {}
    8. storage:
    9. resources:
    10. requests:
    11. storage: <2Gi> (1)
    12. storageClassName: "<storage_class>" (2)
    1Specify the amount of available space requested for the data volume.
    2Optional: If you do not specify a storage class, the default storage class is used.
  2. Create the data volume by running the following command:

    1. $ oc create -f <blank-image-datavolume>.yaml

Additional resources for data volumes