3

I'm trying to re-size the file system on a Centos 7 vm because I made the vm too small to even do a yum update. I already have done some configurations to the virtual machine and it would be pain to do it all over again, so I've been trying to re-size the virtual machine using virt-resize

On the host machine when I run qemu-img info tkk.qcow2 I get the following information

image: tkk.qcow2
file format: qcow2
virtual size: 17G (18253611008 bytes)
disk size: 2.5G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: true

The virtual size used to be smaller but I used qemu-img resize tkk.qcow2 +10G Then I created a backup of the original file tkk.qcow2 with cp tkk.qcow2 tkk-orig.qcow2 and then I ran

virt-resize –expand /dev/sda2 tkk-orig.qcow2 tkk.qcow2 to increase it's size. When I rerun qemu-img info tkk.qcow2 it shows that the Virtual Size has increase by whatever value I added on top of the previous value, but the Disk Size doesn't and I still can't do yum update due to too little space I would like to add at least 5GB more to this minimal vm. The output of

virt-filesystems --long -h --all -a tkk.qcow2

/dev/sda1                 filesystem xfs  -     -   15G  -
/dev/centos_tkk/root filesystem xfs  -     -   1.3G -
/dev/centos_tkk/swap filesystem swap -     -   204M -
/dev/centos_tkk/root lv         -    -     -   1.3G /dev/centos_tkk
/dev/centos_tkk/swap lv         -    -     -   204M /dev/centos_tkk
/dev/centos_tkk      vg         -    -     -   1.5G /dev/sda2
/dev/sda2                 pv         -    -     -   1.5G -
/dev/sda1                 partition  -    -     83  15G  /dev/sda
/dev/sda2                 partition  -    -     8e  1.5G /dev/sda
/dev/sda                  device     -    -     -   17G  -

I have been following these steps on this blog https://fatmin.com/2016/12/20/how-to-resize-a-qcow2-image-and-filesystem-with-virt-resize/

Katz
  • 1,021
  • 5
  • 19
  • 36

1 Answers1

1

Since you're using LVM it's necessary to expand the PV (Physical Volume) firstly and then expand the LVM root partition. You can follow this how-to: https://dnaeon.github.io/resizing-a-kvm-disk-image-on-lvm-the-hard-way/

DarkVex
  • 273
  • 1
  • 6