Resize an image not in use but linked to a clone

josood

New Member
May 6, 2022
5
0
1
I have just one VM (ID 100) but directory images: has the following content:
pvesm list images Volid Format Type Size VMID images:102/base-102-disk-0.qcow2 qcow2 images 53687091200 102 images:102/base-102-disk-0.qcow2/100/vm-100-disk-0.qcow2 qcow2 images 53687091200 100 images:iso/CentOS-8.2.2004-x86_64-minimal.iso iso iso 1718616064

I tried to remove 102/base-102-disk-0.qcow2 but I can't because it is in use by linked clones.

I need to clone a machine unfortunately my images directory has no space so I'd like to know if I can use
Code:
qemu-img resize --shrink base-102-disk-0.qcow2 -10G
and if this execution will not affect the image base-102-disk-0.qcow2/100/vm-100-disk-0.qcow2 qcow2
Thanks
 
Actually shrinking it to a new size will most likely be a problem. Converting it to another qcow2 file and then renaming it to the original name would be the only option. In this case it should only reclaim any space that are zeros. The result might be a bit smaller, or a lot, depending on how many zeros can be stored more efficiently.

Make sure that any linked clones are powered while you do this!

The other option would be to "Move" the disk images to a different storage and then back. This will make them a full clone and there will not be any dependency on the template. Though if you are already low on space, this might not work.
 
Actually shrinking it to a new size will most likely be a problem. Converting it to another qcow2 file and then renaming it to the original name would be the only option. In this case it should only reclaim any space that are zeros. The result might be a bit smaller, or a lot, depending on how many zeros can be stored more efficiently.

Make sure that any linked clones are powered while you do this!

The other option would be to "Move" the disk images to a different storage and then back. This will make them a full clone and there will not be any dependency on the template. Though if you are already low on space, this might not work.
Thanks for you reply Aaron! If the movement you mentioned makes a full clone I think I can delete the image used by VM 102 (doesn't exist) later.

Actually my local-lvm has 319.60 GB of space so I can use that to move the images. Could you please help me with this?

Thanks
Josood
 
Via the GUI: select the disk in the VM and then choose "Move disk" and select the target storage. If you have installed updates recently, it is also possible that you need to click the "Disk Action" button first.
 
Via the GUI: select the disk in the VM and then choose "Move disk" and select the target storage. If you have installed updates recently, it is also possible that you need to click the "Disk Action" button first.
Thanks Aaron! The VM is up and running, may I do this change without affecting the service? or I need to stop the VM first?

Regards
 
Yep, this can be done with the VM running.

If you ever want to do it with containers: they need to be shutdown for a move volume operation.