×

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.

Increasing a VM disk size by expanding the PVC of the disk

You can increase the size of a virtual machine (VM) disk by expanding the persistent volume claim (PVC) of the disk. To specify the increased PVC volume, you can use the web console with the VM running. Alternatively, you can edit the PVC manifest in the CLI.

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.

Expanding a VM disk PVC in the web console

You can increase the size of a VM disk PVC in the web console without leaving the VirtualMachines page and with the VM running.

Procedure
  1. In the Administrator or Virtualization perspective, open the VirtualMachines page.

  2. Select the running VM to open its Details page.

  3. Select the Configuration tab and click Storage.

  4. Click the options menu kebab next to the disk you want to expand. Select the Edit option.

    The Edit disk dialog opens.

  5. In the PersistentVolumeClaim size field, enter the desired size.

  6. Click Save.

You can enter any value greater than the current one. However, if the new value exceeds the available size, an error is displayed.

Expanding a VM disk PVC by editing its manifest

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

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

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
       name: vm-disk-expand
    spec:
      accessModes:
         - ReadWriteMany
      resources:
        requests:
           storage: 3Gi (1)
    # ...
    1 Specify the new disk size.

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

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