Increase a KVM qcow2 Disk Offline (Ubuntu 24.04 + LVM)

Goal: grow /var/lib/libvirt/images/rbe-b.qcow2 offline on the host, then expand LVM inside the Ubuntu 24.04 guest.


TL;DR (commands only)

Host (VM off):

virsh shutdown rbe-b && virsh domstate rbe-b   # wait for "shut off"
sudo qemu-img info /var/lib/libvirt/images/rbe-b.qcow2
sudo qemu-img resize /var/lib/libvirt/images/rbe-b.qcow2 +100G   # or set an absolute size
sudo qemu-img info /var/lib/libvirt/images/rbe-b.qcow2
virsh start rbe-b

Guest (Ubuntu 24.04, LVM on /dev/vda3):

sudo growpart /dev/vda 3
sudo pvresize /dev/vda3
sudo lvextend -r -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

Verify:

lsblk -f
df -hT
sudo pvs; sudo vgs; sudo lvs

Prerequisites

  • Host uses libvirt/KVM and qcow2.
  • Guest is Ubuntu 24.04 with root on LVM (typical: PV /dev/vda3, VG ubuntu-vg, LV ubuntu-lv).
  • growpart available in guest (cloud-guest-utils).

  1. Host: enlarge rbe-b.qcow2 (offline only)
  • Power off and confirm state:
virsh shutdown rbe-b
virsh domstate rbe-b     # expect: shut off
  • Inspect and grow the image:
sudo qemu-img info /var/lib/libvirt/images/rbe-b.qcow2
sudo qemu-img resize /var/lib/libvirt/images/rbe-b.qcow2 +100G
sudo qemu-img info /var/lib/libvirt/images/rbe-b.qcow2
  • Start the VM:
virsh start rbe-b

Offline resize: the guest will see the larger disk at next boot. No rescan required.


  1. Guest: expand LVM to consume the new space
  • Grow the last partition (assumed /dev/vda3):
sudo growpart /dev/vda 3
  • Tell LVM the PV grew:
sudo pvresize /dev/vda3
  • Extend the root LV and filesystem (ext4/XFS handled by -r):
sudo lvextend -r -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

  1. Verify
lsblk -f          # partition/LVM sizes
df -hT            # filesystem size/type
sudo pvs; sudo vgs; sudo lvs
# Optional (ext4 only) safe check:
sudo e2fsck -fn /dev/mapper/ubuntu--vg-ubuntu--lv

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top