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, VGubuntu-vg, LVubuntu-lv). growpartavailable in guest (cloud-guest-utils).
- 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.
- 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
- 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
Did this guide save you time?
Support this site