User Tools

Site Tools


docu:csheet:sysadm:venv:qemu:resize_qcow2_img

Resize (expand) partitions on a qcow2 image using qemu-img and virt-resize


In case you have no space left on the virtual machine, and you had specified a low maximum allocation for the qcow2 image… you can dump the partitions to a new qcow2 image with higher maximum allocation. Here is how to do it:

# create a new empty qcow2 image of maximum allocation space = 20GB
qemu-img create -f qcow2 your-vm-image.NEW.qcow2 20G
 
# imagine that on the virtual machine system partitions we have this:
/dev/sda1        # the root partition (/)
/dev/sda2        # boot or swap partition
 
# in this case we will want to expand the /dev/sda1 (internally on VM, not on the real host),
# we will use this command
virt-resize --expand /dev/sda1 your-vm-image.OLD.qcow2 your-vm-image.NEW.qcow2


Now carefully boot the VM with the new image without deleting the old one to make sure it boots!


Source: https://www.cyberithub.com/resize-qcow2-image-with-virt-resize-kvm-tools/

docu/csheet/sysadm/venv/qemu/resize_qcow2_img.txt · Last modified: 2020/09/25 10:58 by admin