Skip to main content

Rob Pankow Rob Pankow

How to Expand a VM Disk on OpenShift Virtualization While the VM Runs

Oct 22, 2026  |  10 min read

Last edited: Oct 27, 2026

How to Expand a VM Disk on OpenShift Virtualization While the VM Runs

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:

  1. Kubernetes sees a larger spec.resources.requests.storage on the PVC and asks the CSI driver to grow the volume.
  2. The CSI driver grows the backing volume on the storage system.
  3. 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.img on 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.

  1. 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 false means expansion is off. Red Hat’s OpenShift 4.22 storage guide sets the field with oc edit storageclass <storage-class>.

  2. 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.

  3. Upstream KubeVirt has the feature gate. Before KubeVirt v1.9.0, ExpandDisks is an Alpha feature gate, so you add it to spec.configuration.developerConfiguration.featureGates in 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.

  4. 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 dataVolume entry points to a PVC with the same name, because the Containerized Data Importer (CDI) creates the PVC under the DataVolume’s name. Block means the guest gets a raw block volume; Filesystem means a disk.img file on a file system.

  5. 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 Snapshot feature gate in the KubeVirt custom resource; from v1.9.0, Snapshot is 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/v1beta1
    kind: VirtualMachineSnapshot
    metadata:
    name: before-expand
    spec:
    source:
    apiGroup: kubevirt.io
    kind: VirtualMachine
    name: <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: true with oc edit storageclass when 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):

  1. Open the VirtualMachines page in the Administrator or Virtualization perspective.
  2. Select the running VM, then the Configuration tab, then Storage.
  3. Open the options menu next to the disk and select Edit.
  4. 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:

Terminal window
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:

Terminal window
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.

StepPreconditionVerificationRollback
Check StorageClass and driverAccess to the StorageClassallowVolumeExpansion is trueNone needed
Snapshot the VMVolumeSnapshotClass for the StorageClassVirtualMachineSnapshot is ReadyNone needed
Raise the PVC sizeNew size larger than the current oneResizing clears, capacity shows the new sizeRetry smaller if it fails; no shrink
Grow the guest partition and file systemGuest sees the larger diskdf -h or Disk Management shows the spaceStop 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:

Terminal window
sudo growpart /dev/vda 1 # extend partition 1 to the end of the disk
sudo xfs_growfs / # XFS: grow the mounted file system
sudo resize2fs /dev/vda1 # ext4: grow the mounted file system instead

If 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.

1. After the PVC expansion
Root disk /dev/vda: the new space sits unallocated at the end
Partition 1
Unallocated
2growpart /dev/vda 1extends partition 1 to the end of the disk
3. Grow the file system
xfs_growfs / (XFS) or resize2fs /dev/vda1 (ext4), while mounted
Partition 1
+ added space
Windows: check this first on migrated VMs
Volume
Recovery partition
Unallocated
A partition in between blocks Extend Volume
Figure 1: growing the partition and file system in the guest

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.

Filesystem mode
Guest partition and file system
The guest step
You
disk.img file
Grown to fill the new space
KubeVirt
File system on the PVC
Grown in place, no command in the pod
CSI driver
simplyblock logical volume
Grown online
CSI driver
Block mode
Guest partition and file system
The guest step
You
Raw block device
The VM is told the new size
KubeVirt
simplyblock logical volume
Grown online
CSI driver
Grows after you raise the PVC sizeYour stepRequests round up to the next full GiB
Figure 2: what grows where, by volume mode

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.

You may also like:

Kubernetes Storage 201: Concepts and Practical Examples
Kubernetes Storage 201: Concepts and Practical Examples

Kubernetes storage is a sophisticated ecosystem designed to address the complex data management needs of containerized applications. At its core, Kubernetes storage provides a flexible mechanism to…

Ephemeral Storage in Kubernetes: Why It Silently Breaks Stateful Workloads
Ephemeral Storage in Kubernetes: Why It Silently Breaks Stateful Workloads

emptyDir and other ephemeral storage look fast and simple, until a pod eviction or node failure erases the data. Here is what actually happens, and how NVMe/TCP persistent volumes give you the same latency without the risk.

What is a Kubernetes Persistent Volume?
What is a Kubernetes Persistent Volume?

A persistent volume is a slice of storage provisioned by a Kubernetes administrator that can be attached and mounted to pods. Like everything in Kubernetes, it is a resource inside the cluster, and…