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
Edit the
PersistentVolumeClaim
manifest of the VM disk that you want to expand:$ oc edit pvc <pvc_name>
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.
Additional resources for volume expansion
Extending an existing file system partition without destroying data in Red Hat Enterprise Linux
Extending a logical volume and its file system online in Red Hat Enterprise Linux
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
Create a
DataVolume
manifest as shown in the following example:Example
DataVolume
manifestapiVersion: 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. Create the data volume by running the following command:
$ oc create -f <blank-image-datavolume>.yaml
Additional resources for data volumes