To expand a VM disk on Red Hat® OpenShift® Virtualization, you raise the size of the PersistentVolumeClaim (PVC) behind the disk. If the StorageClass allows expansion and the CSI driver supports it, the volume grows while the VM keeps running. You then grow the partition and file system inside the guest, just as you did after extending a VMDK.
The steps apply to OpenShift Virtualization and to upstream KubeVirt. Shrinking a disk and moving VMs off vSphere are out of scope.
What replaces “extend the VMDK”
Growing a VM disk still has the two halves you know from vSphere: the virtual disk first, then the partition and file system in the guest. What differs is the first half: it is now a change to a Kubernetes object, carried out by three components.
In VMware® vSphere you edited the VM. Broadcom KB 344854 lists the conditions: all snapshots removed, and the VM powered off unless the disk sits on a PVSCSI controller (hot extend from vSphere 7.0) or an NVMe controller (from vSphere 8.0.1).
On OpenShift Virtualization the disk is a PVC, and one field change sets off the chain:
- Kubernetes sees a larger
spec.resources.requests.storageon the PVC and asks the CSI driver to grow the volume. - The CSI driver grows the backing volume on the storage system.
- KubeVirt tells the running VM that the disk changed size. If the PVC uses Filesystem volume mode, the disk is a raw file named
disk.imgon that volume, and KubeVirt grows the file to fill the new space.
For how growing disks change your pool forecast, see VMware capacity planning after the exit.
Prerequisites to expand a VM disk on OpenShift Virtualization
Four checks decide whether a running VM’s disk can grow, and a fifth step gives you a way back. Run them before you touch the size.
-
The StorageClass allows expansion. Kubernetes expands a PVC only if its StorageClass has
allowVolumeExpansion: true. Check it:Terminal window oc get storageclass <storage-class> -o jsonpath='{.allowVolumeExpansion}'An empty result or
falsemeans expansion is off. Red Hat’s OpenShift 4.22 storage guide sets the field withoc edit storageclass <storage-class>. -
The CSI driver supports expansion. The Kubernetes documentation says CSI expansion also needs a driver that implements it. Check your storage vendor’s documentation, not only the StorageClass flag.
-
Upstream KubeVirt has the feature gate. Before KubeVirt v1.9.0,
ExpandDisksis an Alpha feature gate, so you add it tospec.configuration.developerConfiguration.featureGatesin the KubeVirt custom resource. From v1.9.0 it is GA and always on. Red Hat’s OpenShift 4.22 virtualization documentation expands a running VM’s disk from the console and lists no gate to enable. -
You know the PVC and its volume mode. List the VM’s volumes, then read the volume mode of the PVC:
Terminal window oc get vm <vm> -n <namespace> -o jsonpath='{.spec.template.spec.volumes}'oc get pvc <pvc> -n <namespace> -o jsonpath='{.spec.volumeMode}'A
dataVolumeentry points to a PVC with the same name, because the Containerized Data Importer (CDI) creates the PVC under the DataVolume’s name.Blockmeans the guest gets a raw block volume;Filesystemmeans adisk.imgfile on a file system. -
Take a rollback point. A VirtualMachineSnapshot captures the VM and its disks, running or stopped. It needs a VolumeSnapshotClass for the disk’s StorageClass. On upstream KubeVirt before v1.9.0, it also needs the
Snapshotfeature gate in the KubeVirt custom resource; from v1.9.0,Snapshotis a Beta gate that is on by default. If the QEMU guest agent runs, it freezes the guest file systems during the snapshot. The quiescing tradeoff is explained in who quiesces the guest after the vSphere exit.apiVersion: snapshot.kubevirt.io/v1beta1kind: VirtualMachineSnapshotmetadata:name: before-expandspec:source:apiGroup: kubevirt.iokind: VirtualMachinename: <vm>Wait for it with
oc wait vmsnapshot before-expand -n <namespace> --for condition=Ready.
When a check fails, the fix depends on which one:
- Set
allowVolumeExpansion: truewithoc edit storageclasswhen only the flag is off and the driver supports expansion. - Choose a blank DataVolume when the driver cannot expand and the guest can use a second disk, for example a new data mount. The Red Hat procedure creates one with
source: blank: {}. - Choose a new, expandable StorageClass and move the disk to it when the boot or data disk itself must grow. The ways to move a VM disk between StorageClasses are covered in what replaces vMotion and Storage vMotion.
Expand the disk while the VM runs
You can make the change from the console or the CLI, and both edit the same PVC field.
From the console (Red Hat OpenShift 4.22 virtualization procedure):
- Open the VirtualMachines page in the Administrator or Virtualization perspective.
- Select the running VM, then the Configuration tab, then Storage.
- Open the options menu next to the disk and select Edit.
- Enter the new value in the PersistentVolumeClaim size field and click Save. A value above the available size shows an error.
From the CLI, the documented path is oc edit pvc <pvc> and a new spec.resources.requests.storage. A one-line equivalent, shown as an example for a disk going to 150 GiB:
oc patch pvc <pvc> -n <namespace> --type merge \ -p '{"spec":{"resources":{"requests":{"storage":"150Gi"}}}}'Edit the PVC, never the PersistentVolume. The Kubernetes documentation warns that editing a PV’s capacity directly can prevent the automatic resize, because the control plane concludes no resize is needed.
To verify, watch the PVC. OpenShift adds a Resizing condition while the expansion runs and removes it when the expansion completes, and the PVC then reports the new size:
oc get pvc <pvc> -n <namespace> -o jsonpath='{.status.capacity.storage}'oc describe pvc <pvc> -n <namespace>If the request fails, for example because the pool lacks capacity, Kubernetes keeps retrying. You can request a smaller size, as long as it is larger than .status.capacity, and follow the result in .status.allocatedResourceStatuses and the PVC events. In-use PVC expansion has been stable since Kubernetes v1.24, so you do not delete or restart the VM’s pod.
| Step | Precondition | Verification | Rollback |
|---|---|---|---|
| Check StorageClass and driver | Access to the StorageClass | allowVolumeExpansion is true | None needed |
| Snapshot the VM | VolumeSnapshotClass for the StorageClass | VirtualMachineSnapshot is Ready | None needed |
| Raise the PVC size | New size larger than the current one | Resizing clears, capacity shows the new size | Retry smaller if it fails; no shrink |
| Grow the guest partition and file system | Guest sees the larger disk | df -h or Disk Management shows the space | Stop the VM, restore the snapshot |
Existing snapshots keep the content they captured. Restoring one needs the VM stopped, or a StopTarget readiness policy that stops it for you, and returns the disks to that point, partition table included. Plan to repeat the expansion and the guest step after a restore.
Grow the partition and file system in the guest
The guest now has a larger disk with the extra space unallocated at the end. Check it first with lsblk on Linux or Disk Management on Windows.
On Linux, with example device names for a root disk on /dev/vda, partition 1:
sudo growpart /dev/vda 1 # extend partition 1 to the end of the disksudo xfs_growfs / # XFS: grow the mounted file systemsudo resize2fs /dev/vda1 # ext4: grow the mounted file system insteadIf growpart is missing, install the package your distribution ships it in. xfs_growfs and resize2fs both work on mounted file systems. If the guest uses LVM, run pvresize on the partition and lvextend -r on the logical volume instead of growing the file system directly.
On Windows, right-click the volume in Disk Management and select Extend Volume. In PowerShell, Get-PartitionSupportedSize returns the maximum size and Resize-Partition applies it. On migrated VMs, check Microsoft’s condition first: the unallocated space must sit directly after the volume you extend, so a partition between them, such as a recovery partition, blocks the extension.
What the storage layer does during the expansion
With simplyblock, the volume behind the PVC grows online: the CSI driver in the 26.3 release supports online expansion of its logical volumes. You enable it with allowVolumeExpansion: true on a StorageClass that uses the csi.simplyblock.io provisioner. One limit in 26.3: a logical volume clone cannot be resized yet. If the disk was cloned from a boot source or restored from a snapshot, check the 26.3 known issues before you plan an online expansion.
For a Filesystem-mode volume, the driver grows the logical volume and then, in place, the file system on the PVC that holds disk.img, with no command inside the pod. The guest file system still needs the guest step. For a raw block volume, the device grows at the storage layer, and KubeVirt then tells the VM about the new size. Volumes are allocated on GiB boundaries, so a request rounds up to the next full GiB.
The same StorageClass and the same PVC field serve VM disks and container volumes, so a disk resize runs the way any other volume resize does on the cluster. More on running VMs and containers on one storage layer is in storage for OpenShift Virtualization, and the VM-side architecture is in the KubeVirt persistent storage guide. How volume mode and StorageClass get chosen at import time is covered in the storage decisions MTV makes for you.
Questions and Answers
Can I shrink a VM disk on OpenShift Virtualization?
No. Red Hat’s OpenShift 4.22 virtualization documentation states that you cannot reduce the size of a VM disk, and Kubernetes rejects a smaller spec.resources.requests.storage on an existing PVC. To get a smaller disk, create a new, smaller disk and copy the data inside the guest.
What happens if I expand the disk of a stopped VM?
Kubernetes accepts the new size, but the Kubernetes documentation says a PVC that no pod uses cannot finish expanding until a pod uses it. For a VM, that pod is the one that starts with the VM, so expect the expansion to complete at the next VM start, and grow the guest partition after that.
Why does the guest see a smaller disk than the PVC size?
On a Filesystem-mode PVC, the VM disk is a disk.img file on a file system, and KubeVirt reserves some space for file system overhead when it creates or grows that file. KubeVirt also tolerates up to 10% less space than requested by default, set by pvcTolerateLessSpaceUpToPercent in the KubeVirt custom resource. A Block-mode PVC hands the VM the device itself, so no file system overhead applies.