Increase the size of a LibVirt/KVM Volume

increase the size of a libvirt/kvm volume

Sometimes you create a virtual machine in Libvirt/KVM with a qcow2 disk and later realise you need more space.
The good news is you can expand the disk without rebuilding the VM. This post walks through the process step by step.


1. Shut down the VM

It’s safest to resize while the VM is powered off.

# Shutdown the vm
virsh shutdown <vm-name>
# Confirm the vm is shutdown
virsh list --all

2. Resize the qcow2 image

On the host, increase the size of the disk file. You can either grow by a delta or set an absolute size.

# Add 500 GB
qemu-img resize /var/lib/libvirt/images/<vm-name>.qcow2 +500G

# Or set to a fixed size (2 TB total)
qemu-img resize /var/lib/libvirt/images/<vm-name>.qcow2 2T

3. Start the VM

Bring the VM back up:

virsh start <vm-name>

4. Grow the partition inside the VM

Inside the VM, check what the disk looks like:

lsblk

If your root/data partition is /dev/vda1, you can expand it:

# Expand the partition
sudo growpart /dev/vda 1

# Resize the filesystem
# For ext4:
sudo resize2fs /dev/vda1

# For XFS:
sudo xfs_growfs /

Now the OS can use the additional space.

5. Verify the new size

You should see the extra capacity available

dh -h

Notes & Tips

  • You can run qemu-img resize while the VM is running, but the guest won’t see the change until a rescan or reboot.
  • If you use LVM inside the VM, you’ll also need pvresize and lvextend before running resize2fs or xfs_growfs.
  • For storage nodes (e.g. Longhorn or Ceph), make sure you resize the data disk partition, not just the root disk, so the cluster sees the capacity.