Running out of disk space on a KVM guest is inevitable. The question is whether you can expand it without rebuilding the VM. With virt-resize, you can grow a guest disk image and resize its partitions while the VM is offline. It works by copying the original disk to a new, larger image with adjusted partition sizes, leaving the original intact as a backup.
This guide covers two approaches: qemu-img resize for simple disk expansion (when you just need more space and will handle partitions inside the guest), and virt-resize for offline partition resizing from the host. Both standard partitions and LVM layouts are covered.
Tested March 2026 on Ubuntu 24.04 LTS (kernel 6.8, QEMU 8.2.2, virt-resize 1.52.0, libguestfs-tools 1.52)
Install libguestfs-tools
The virt-resize command is part of the libguestfs-tools package. Install it on the KVM host (not inside the guest).
On Rocky Linux / AlmaLinux / RHEL:
sudo dnf install -y guestfs-tools
On Ubuntu / Debian:
sudo apt install -y libguestfs-tools
This also installs virt-df, virt-filesystems, virt-sparsify, and other useful utilities for working with guest disk images. For a full list of KVM management commands, see our virsh commands cheat sheet.
Method 1: Simple Disk Expansion with qemu-img resize
If you just need to make the virtual disk larger and plan to resize partitions from inside the guest after booting, qemu-img resize is the fastest approach. It modifies the disk image in place.
Shut down the VM first:
virsh shutdown myvm
Check the current disk size:
qemu-img info /var/lib/libvirt/images/myvm.qcow2
Add 30GB to the disk (the + means “add to existing size”):
qemu-img resize /var/lib/libvirt/images/myvm.qcow2 +30G
The output confirms the resize:
Image resized.
Start the VM and resize the partition from inside the guest. The unallocated space appears at the end of the disk, and you need to grow the partition to use it. For ext4 on a standard partition:
sudo growpart /dev/vda 1
sudo resize2fs /dev/vda1
For XFS (common on RHEL/Rocky):
sudo growpart /dev/vda 1
sudo xfs_growfs /
This method is simple but requires booting the guest to finish the resize. If you need to resize partitions without booting the guest (for example, when the guest OS is broken or you want to restructure partitions), use virt-resize instead.
Method 2: Offline Partition Resize with virt-resize
virt-resize copies the original disk to a new, larger disk while resizing partitions in the process. The original disk is never modified, which gives you a built-in rollback. The trade-off is that you need enough free space on the host for both the old and new disk images.
Inspect the current disk layout
Shut down the VM and set the disk path as a variable for convenience:
virsh shutdown myvm
DISK=/var/lib/libvirt/images/myvm.qcow2
Check the current partition layout and disk usage:
sudo virt-filesystems --all --long -a $DISK
Output shows every partition, filesystem, and device in the image:
Name Type VFS Label MBR Size Parent
/dev/sda1 filesystem ext4 - - 20961435648 -
/dev/sda14 filesystem unknown - - 3145728 -
/dev/sda15 filesystem vfat - - 129718272 -
/dev/sda1 partition - - - 21340601856 /dev/sda
/dev/sda14 partition - - - 3145728 /dev/sda
/dev/sda15 partition - - - 130023424 /dev/sda
/dev/sda device - - - 21474836480 -
Check how much space is used inside each filesystem:
sudo virt-df -h -a $DISK
Shows usage by mount point:
Filesystem Size Used Available Use%
myvm.qcow2:/dev/sda1 20G 1.2G 18G 7%
myvm.qcow2:/dev/sda15 124M 12M 112M 10%
Create the new disk and resize
Create a new, larger disk image. This example creates a 50GB disk:
qemu-img create -f qcow2 -o preallocation=metadata /var/lib/libvirt/images/myvm-new.qcow2 50G
Run virt-resize to copy the old disk into the new one with resized partitions. The --expand flag tells it which partition should absorb the extra space:
sudo virt-resize \
--expand /dev/sda1 \
$DISK /var/lib/libvirt/images/myvm-new.qcow2
The tool prints a summary of what it will do, copies the data, and expands the filesystem:
Summary of changes:
virt-resize: /dev/sda14: This partition will be left alone.
virt-resize: /dev/sda15: This partition will be left alone.
virt-resize: /dev/sda1: This partition will be resized from 19.9G to 49.5G.
The filesystem ext4 on /dev/sda1 will be expanded using the 'resize2fs' method.
[ 1.5] Setting up initial partition table on myvm-new.qcow2
[ 12.2] Copying /dev/sda14
[ 12.2] Copying /dev/sda15
[ 12.3] Copying /dev/sda1
100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
[ 21.4] Expanding /dev/sda1 using the 'resize2fs' method
virt-resize: Resize operation completed with no errors.
You can also resize specific partitions to exact sizes using --resize. For example, to expand the EFI boot partition to 500MB and let the root partition take the rest:
sudo virt-resize \
--resize /dev/sda15=500M \
--expand /dev/sda1 \
$DISK /var/lib/libvirt/images/myvm-new.qcow2
Replace the old disk and start the VM
Verify the new disk before replacing the original:
qemu-img info /var/lib/libvirt/images/myvm-new.qcow2
Confirm the virtual size shows 50 GiB:
image: myvm-new.qcow2
file format: qcow2
virtual size: 50 GiB (53687091200 bytes)
disk size: 1.47 GiB
cluster_size: 65536
Replace the old disk with the new one:
sudo mv /var/lib/libvirt/images/myvm-new.qcow2 $DISK
Start the VM and verify from inside the guest:
sudo virsh start myvm
Log in and confirm the partition has grown:
df -hT
The root filesystem now shows the expanded size:
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda3 ext4 49G 1.2G 46G 3% /
/dev/vda2 vfat 124M 12M 113M 10% /boot/efi
Resize LVM-Based Guest Disks
Many RHEL, Rocky, and AlmaLinux installations use LVM by default. After expanding the disk image (using either method above), you need to grow the LVM physical volume, logical volume, and filesystem from inside the guest.
First, check the current layout:
lsblk
sudo vgs
sudo lvs
Grow the partition to fill the available space (if using qemu-img resize):
sudo growpart /dev/vda 2
Resize the physical volume to recognize the new partition size:
sudo pvresize /dev/vda2
Extend the logical volume to use all free space in the volume group. The -r flag automatically resizes the filesystem after extending:
sudo lvextend -r -l +100%FREE /dev/mapper/rl-root
Replace rl-root with your actual volume group and logical volume name (visible in lvs output). On Ubuntu, the default is typically ubuntu--vg-ubuntu--lv.
If you skipped -r, resize the filesystem manually. For ext4:
sudo resize2fs /dev/mapper/rl-root
For XFS (default on Rocky/RHEL):
sudo xfs_growfs /
Verify the new size:
df -hT /
Shrink a Guest Disk with virt-sparsify
If your qcow2 disk image has grown larger than the actual data it contains (common after deleting files inside the guest), virt-sparsify reclaims that wasted space. This does not change the virtual disk size but reduces the physical file size on the host.
sudo virt-sparsify --in-place $DISK
Or create a sparsified copy (safer, preserves original):
sudo virt-sparsify $DISK /var/lib/libvirt/images/myvm-sparse.qcow2
On our test system, a 10GB virtual disk containing 922MB of data went from 11GB on disk down to 1.1GB after sparsify.
virt-resize Quick Reference
| Flag | Purpose | Example |
|---|---|---|
--expand /dev/sdaN | Expand partition to fill remaining space | --expand /dev/sda1 |
--resize /dev/sdaN=SIZE | Resize partition to exact size | --resize /dev/sda15=500M |
--shrink /dev/sdaN | Shrink a partition (use with caution) | --shrink /dev/sda2 |
--no-expand-content | Resize partition but not the filesystem inside | When you want manual filesystem control |
--ntfsresize-force | Force NTFS resize (Windows guests) | When resizing Windows VM disks |
When to Use Which Method
| Scenario | Method |
|---|---|
| Quick expand, guest OS is healthy | qemu-img resize + growpart inside guest |
| Need to resize partitions without booting | virt-resize from host |
| Guest OS is broken or unbootable | virt-resize from host |
| Restructure partition layout | virt-resize with --resize and --expand |
| LVM guest, just need more space | qemu-img resize + pvresize/lvextend inside |
| Reclaim wasted qcow2 space | virt-sparsify |
If you are new to KVM, start with our guide on installing KVM on Rocky Linux 10.